Class TupleConstructorASTTransformation

java.lang.Object
org.codehaus.groovy.transform.AbstractASTTransformation
org.codehaus.groovy.transform.TupleConstructorASTTransformation
All Implemented Interfaces:
CompilationUnitAware, ASTTransformation, ErrorCollecting, TransformWithPriority

public class TupleConstructorASTTransformation extends AbstractASTTransformation implements CompilationUnitAware, TransformWithPriority
Handles generation of code for the @TupleConstructor annotation.
  • Constructor Details

    • TupleConstructorASTTransformation

      public TupleConstructorASTTransformation()
  • Method Details

    • priority

      public int priority()
      Description copied from interface: TransformWithPriority
      Returns the order of this transform among others in the same phase. Higher values run first. The default used by transforms that do not implement this interface is zero.
      Specified by:
      priority in interface TransformWithPriority
      Returns:
      the priority
    • getAnnotationName

      public String getAnnotationName()
      Description copied from class: AbstractASTTransformation
      If the transform is associated with a single annotation, returns a name suitable for displaying in error messages.
      Overrides:
      getAnnotationName in class AbstractASTTransformation
      Returns:
      The simple name of the annotation including the "@" or null if no such name is defined
    • setCompilationUnit

      public void setCompilationUnit(CompilationUnit unit)
      Description copied from interface: CompilationUnitAware
      Sets the compilation unit currently applying this transformation.
      Specified by:
      setCompilationUnit in interface CompilationUnitAware
      Parameters:
      unit - the active compilation unit
    • visit

      public void visit(ASTNode[] nodes, SourceUnit source)
      Description copied from interface: ASTTransformation
      The method is invoked when an AST Transformation is active. For local transformations, it is invoked once each time the local annotation is encountered. For global transformations, it is invoked once for every source unit, which is typically a source file.
      Specified by:
      visit in interface ASTTransformation
      Parameters:
      nodes - The ASTnodes when the call was triggered. Element 0 is the AnnotationNode that triggered this annotation to be activated. Element 1 is the AnnotatedNode decorated, such as a MethodNode or ClassNode. For global transformations it is usually safe to ignore this parameter.
      source - The source unit being compiled. The source unit may contain several classes. For global transformations, information about the AST can be retrieved from this object.
    • selectTupleProperties

      Resolves the property nodes the @TupleConstructor runtime transform would use as constructor parameters. Honours includes, excludes, allNames, includeProperties, includeFields, includeSuperProperties, includeSuperFields, and allProperties attributes the same way the full transform does so the joint-compilation stubber stays in lockstep.
      Since:
      6.0.0
    • addSpecialMapConstructors

      public static void addSpecialMapConstructors(int modifiers, ClassNode cNode, String message, boolean addNoArg)
      Adds a generated constructor that takes a LinkedHashMap named __namedArgs. A null map throws IllegalArgumentException with message from that constructor. Otherwise each instance property whose name is a key of the map is assigned from that entry, and the keys are checked against the property names. When addNoArg is true, a no-arg constructor that calls this(new LinkedHashMap()) is added as well.
      Parameters:
      modifiers - access flags of the generated constructors
      cNode - class that receives the constructors
      message - exception text used when the map is null
      addNoArg - whether to also add the no-arg constructor