Record Class CompositeCodeTransformer

java.lang.Object
java.lang.Record
com.google.errorprone.CompositeCodeTransformer
All Implemented Interfaces:
CodeTransformer, Serializable

public record CompositeCodeTransformer(com.google.common.collect.ImmutableList<CodeTransformer> transformers) extends Record implements CodeTransformer, Serializable
Combines multiple CodeTransformers into one.
See Also:
  • Constructor Details

    • CompositeCodeTransformer

      public CompositeCodeTransformer(com.google.common.collect.ImmutableList<CodeTransformer> transformers)
      Creates an instance of a CompositeCodeTransformer record class.
      Parameters:
      transformers - the value for the transformers record component
  • Method Details

    • compose

      public static CodeTransformer compose(CodeTransformer... transformers)
    • compose

      public static CodeTransformer compose(Iterable<? extends CodeTransformer> transformers)
    • apply

      public void apply(TreePath path, com.sun.tools.javac.util.Context context, DescriptionListener listener)
      Description copied from interface: CodeTransformer
      Apply recursively from the leaf node in the given TreePath.
      Specified by:
      apply in interface CodeTransformer
    • annotations

      public com.google.common.collect.ImmutableClassToInstanceMap<Annotation> annotations()
      Description copied from interface: CodeTransformer
      Returns a map of annotation data logically applied to this code transformer.

      As an example, if a CodeTransformer expressed as a Refaster rule had an annotation applied to it:

      @MyCustomAnnotation("value")
      public class AnnotatedRefasterRule {
         @BeforeTemplate void before(String x) {...}
         @AfterTemplate void after(String x) {...}
      }
      
      You could retrieve the value of @MyCustomAnnotation from this map.
      Specified by:
      annotations in interface CodeTransformer
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • transformers

      public com.google.common.collect.ImmutableList<CodeTransformer> transformers()
      Returns the value of the transformers record component.
      Returns:
      the value of the transformers record component