Class ReplaceFieldComparisonWithInstanceOf

All Implemented Interfaces:
ClassProcessor

public class ReplaceFieldComparisonWithInstanceOf extends SimpleMethodProcessor
Replaces code such as itemstack.getItem() == Items.CROSSBOW with instanceof checks such as itemstack.getItem() instanceof CrossbowItem. This transformer targets a set of methods to replace the occurrence of a single field-comparison.
  • Field Details

    • LOG

      private static final org.slf4j.Logger LOG
    • targets

      private final Set<SimpleMethodProcessor.Target> targets
    • fieldOwner

      private final String fieldOwner
    • fieldName

      private final String fieldName
    • replacementClassName

      private final String replacementClassName
  • Constructor Details

    • ReplaceFieldComparisonWithInstanceOf

      public ReplaceFieldComparisonWithInstanceOf(String fieldOwner, String fieldName, String replacementClassName, List<SimpleMethodProcessor.Target> methodsToScan)
      Parameters:
      fieldOwner - The class that owns fieldName
      fieldName - The name of a field in fieldOwner
      replacementClassName - Reference comparisons against fieldName in fieldOwner are replaced by instanceof checks against this class.
      methodsToScan - The methods to scan
  • Method Details