AbstractGrailsArtefactTransformer (Grails 6.0.0)

Package: org.grails.compiler.injection

## [Java] Class AbstractGrailsArtefactTransformer

- org.grails.compiler.injection.AbstractGrailsArtefactTransformer

- All Implemented Interfaces and Traits:
    AnnotatedClassInjector, GrailsArtefactClassInjector, java.lang.Comparable

      @java.lang.SuppressWarnings("rawtypes")
      public abstract class AbstractGrailsArtefactTransformer
      extends java.lang.Object
      implements AnnotatedClassInjector, GrailsArtefactClassInjector, java.lang.Comparable

  Abstract transformer that takes an implementation class and creates methods in a target ClassNode that delegate to that implementation class. Subclasses should override to provide the implementation class details

  Since:
    2.0
  Authors:
    Graeme Rocher

- - ### Field Summary

    Fields
    Modifiers | Name | Description
    --- | --- | ---
    `private static org.codehaus.groovy.ast.AnnotationNode` | `AUTO_WIRED_ANNOTATION` |
    `static java.lang.String` | `CURRENT_PREFIX` |
    `private static java.lang.String[]` | `DEFAULT_GENERICS_PLACEHOLDERS` |
    `private static java.lang.String` | `INSTANCE_PREFIX` |
    `private static java.util.Set<java.lang.String>` | `KNOWN_TRANSFORMED_CLASSES` |
    `static java.lang.String` | `METHOD_MISSING_METHOD_NAME` |
    `protected static org.codehaus.groovy.ast.ClassNode` | `OBJECT_CLASS` |
    `static int` | `PUBLIC_STATIC_MODIFIER` |
    `static java.lang.String` | `STATIC_METHOD_MISSING_METHOD_NAME` |
    `private static java.lang.String` | `STATIC_PREFIX` |
    `private java.util.Set<java.lang.String>` | `classesTransformedByThis` |

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `protected void` | `addApiLookupFieldAndSetter(org.codehaus.groovy.ast.ClassNode classNode, org.codehaus.groovy.ast.ClassNode implementationNode, java.lang.String apiProperty, org.codehaus.groovy.ast.expr.Expression initialValueExpression)`
    `` | `protected void` | `addDelegateInstanceMethod(org.codehaus.groovy.ast.ClassNode classNode, org.codehaus.groovy.ast.expr.Expression delegate, org.codehaus.groovy.ast.MethodNode declaredMethod, org.codehaus.groovy.ast.AnnotationNode markerAnnotation, java.util.Map<java.lang.String, org.codehaus.groovy.ast.ClassNode> genericsPlaceholders)`
    `` | `protected void` | `addDelegateStaticMethod(org.codehaus.groovy.ast.ClassNode classNode, org.codehaus.groovy.ast.expr.MethodCallExpression apiLookupMethod, org.codehaus.groovy.ast.MethodNode declaredMethod, java.util.Map<java.lang.String, org.codehaus.groovy.ast.ClassNode> genericsPlaceholders)`
    `` | `protected void` | `addEnhancedAnnotation(org.codehaus.groovy.ast.ClassNode classNode)`
    `` | `public static void` | `addToTransformedClasses(java.lang.String name)`
    `` | `public void` | `clearCachedState()`
    `` | `public int` | `compareTo(java.lang.Object o)` Used for ordering not equality.
    `` | `private org.codehaus.groovy.ast.MethodNode` | `createStaticLookupMethod(org.codehaus.groovy.ast.ClassNode classNode, org.codehaus.groovy.ast.ClassNode implementationNode, java.lang.String apiProperty, java.lang.String lookupMethodName)`
    `` | `protected java.lang.String` | `getArtefactType()`
    `` | `public java.lang.String[]` | `getArtefactTypes()`
    `` | `public abstract java.lang.Class` | `getInstanceImplementation()` The class that provides the implementation of all instance methods and properties
    `` | `protected org.codehaus.groovy.ast.AnnotationNode` | `getMarkerAnnotation()` A marker annotation to be applied to added methods, defaults to null
    `` | `public abstract java.lang.Class` | `getStaticImplementation()` The class that provides static methods
    `` | `public static java.util.Collection<java.lang.String>` | `getTransformedClassNames()`
    `` | `protected boolean` | `hasArtefactAnnotation(org.codehaus.groovy.ast.ClassNode classNode)`
    `` | `protected boolean` | `isCandidateInstanceMethod(org.codehaus.groovy.ast.ClassNode classNode, org.codehaus.groovy.ast.MethodNode declaredMethod)`
    `` | `protected boolean` | `isStaticCandidateMethod(org.codehaus.groovy.ast.ClassNode classNode, org.codehaus.groovy.ast.MethodNode declaredMethod)`
    `` | `protected boolean` | `isStaticMethodExcluded(org.codehaus.groovy.ast.ClassNode classNode, org.codehaus.groovy.ast.MethodNode declaredMethod)`
    `` | `protected boolean` | `isStaticMethodIncluded(org.codehaus.groovy.ast.ClassNode classNode, org.codehaus.groovy.ast.MethodNode declaredMethod)`
    `` | `protected boolean` | `isValidArtefactType()`
    `` | `private boolean` | `isValidArtefactTypeByConvention(org.codehaus.groovy.ast.ClassNode classNode)`
    `` | `protected boolean` | `isValidTargetClassNode(org.codehaus.groovy.ast.ClassNode classNode)`
    `` | `public void` | `performInjection(org.codehaus.groovy.control.SourceUnit source, org.codehaus.groovy.classgen.GeneratorContext context, org.codehaus.groovy.ast.ClassNode classNode)`
    `` | `public void` | `performInjection(org.codehaus.groovy.control.SourceUnit source, org.codehaus.groovy.ast.ClassNode classNode)`
    `` | `protected void` | `performInjectionInternal(java.lang.String apiInstanceProperty, org.codehaus.groovy.control.SourceUnit source, org.codehaus.groovy.ast.ClassNode classNode)` Subclasses can override to provide additional transformation
    `` | `public void` | `performInjectionOnAnnotatedClass(org.codehaus.groovy.control.SourceUnit source, org.codehaus.groovy.ast.ClassNode classNode)`
    `` | `public void` | `performInjectionOnAnnotatedClass(org.codehaus.groovy.control.SourceUnit source, org.codehaus.groovy.classgen.GeneratorContext context, org.codehaus.groovy.ast.ClassNode classNode)`
    `` | `protected void` | `performInstanceImplementationInjection(org.codehaus.groovy.control.SourceUnit source, org.codehaus.groovy.ast.ClassNode classNode, java.util.Map<java.lang.String, org.codehaus.groovy.ast.ClassNode> genericsPlaceholders, java.lang.Class instanceImplementation)`
    `` | `protected void` | `performStaticImplementationInjection(org.codehaus.groovy.ast.ClassNode classNode, java.util.Map<java.lang.String, org.codehaus.groovy.ast.ClassNode> genericsPlaceholders, java.lang.Class staticImplementation)`
    `` | `protected org.codehaus.groovy.ast.MethodNode` | `populateAutowiredApiLookupMethod(org.codehaus.groovy.ast.ClassNode classNode, org.codehaus.groovy.ast.ClassNode implementationNode, java.lang.String apiProperty, java.lang.String methodName, org.codehaus.groovy.ast.stmt.BlockStatement methodBody)`
    `` | `protected org.codehaus.groovy.ast.MethodNode` | `populateDefaultApiLookupMethod(org.codehaus.groovy.ast.ClassNode implementationNode, java.lang.String apiInstanceProperty, java.lang.String methodName, org.codehaus.groovy.ast.stmt.BlockStatement methodBody)`
    `` | `protected boolean` | `requiresAutowiring()` If the API requires autowiring then a Autowired: property will be added.
    `` | `protected boolean` | `requiresStaticLookupMethod()` Subclasses should override in the instance API requires a static lookup method instead of autowiring.
    `` | `protected java.util.Map<java.lang.String, org.codehaus.groovy.ast.ClassNode>` | `resolveGenericsPlaceHolders(org.codehaus.groovy.ast.ClassNode classNode)`
    `` | `protected boolean` | `shouldSkipInjection(org.codehaus.groovy.ast.ClassNode classNode)`

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class java.lang.Object` | `java.lang.Object#wait(long), java.lang.Object#wait(long, int), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()`

- - ### Field Detail

    - #### private static final org.codehaus.groovy.ast.AnnotationNode AUTO_WIRED_ANNOTATION

    - #### public static final java.lang.String CURRENT_PREFIX

    - #### private static final java.lang.String[] DEFAULT_GENERICS_PLACEHOLDERS

    - #### private static final java.lang.String INSTANCE_PREFIX

    - #### private static final java.util.Set<java.lang.String> KNOWN_TRANSFORMED_CLASSES

    - #### public static final java.lang.String METHOD_MISSING_METHOD_NAME

    - #### protected static final org.codehaus.groovy.ast.ClassNode OBJECT_CLASS

    - #### public static final int PUBLIC_STATIC_MODIFIER

    - #### public static final java.lang.String STATIC_METHOD_MISSING_METHOD_NAME

    - #### private static final java.lang.String STATIC_PREFIX

    - #### private final java.util.Set<java.lang.String> classesTransformedByThis

  - ### Method Detail

    - #### protected void addApiLookupFieldAndSetter(org.codehaus.groovy.ast.ClassNode classNode, org.codehaus.groovy.ast.ClassNode implementationNode, java.lang.String apiProperty, org.codehaus.groovy.ast.expr.Expression initialValueExpression)

    - #### protected void addDelegateInstanceMethod(org.codehaus.groovy.ast.ClassNode classNode, org.codehaus.groovy.ast.expr.Expression delegate, org.codehaus.groovy.ast.MethodNode declaredMethod, org.codehaus.groovy.ast.AnnotationNode markerAnnotation, java.util.Map<java.lang.String, org.codehaus.groovy.ast.ClassNode> genericsPlaceholders)

    - #### protected void addDelegateStaticMethod(org.codehaus.groovy.ast.ClassNode classNode, org.codehaus.groovy.ast.expr.MethodCallExpression apiLookupMethod, org.codehaus.groovy.ast.MethodNode declaredMethod, java.util.Map<java.lang.String, org.codehaus.groovy.ast.ClassNode> genericsPlaceholders)

    - #### protected void addEnhancedAnnotation(org.codehaus.groovy.ast.ClassNode classNode)

    - #### public static void addToTransformedClasses(java.lang.String name)

    - #### public void clearCachedState()

    - #### public int compareTo(java.lang.Object o)

      Used for ordering not equality. Note: this class has a natural ordering that is inconsistent with equals.

      See Also:
        java.lang.Comparable#compareTo(java.lang.Object)

    - #### private org.codehaus.groovy.ast.MethodNode createStaticLookupMethod(org.codehaus.groovy.ast.ClassNode classNode, org.codehaus.groovy.ast.ClassNode implementationNode, java.lang.String apiProperty, java.lang.String lookupMethodName)

    - #### protected java.lang.String getArtefactType()

    - #### public java.lang.String[] getArtefactTypes()

    - #### public abstract java.lang.Class getInstanceImplementation()

      The class that provides the implementation of all instance methods and properties

      Returns:
        A class whose methods contain a first argument of type object that is the instance

    - #### protected org.codehaus.groovy.ast.AnnotationNode getMarkerAnnotation()

      A marker annotation to be applied to added methods, defaults to null

      Returns:
        The annotation node

    - #### public abstract java.lang.Class getStaticImplementation()

      The class that provides static methods

      Returns:
        A class or null if non is provided

    - #### public static java.util.Collection<java.lang.String> getTransformedClassNames()

    - #### protected boolean hasArtefactAnnotation(org.codehaus.groovy.ast.ClassNode classNode)

    - #### protected boolean isCandidateInstanceMethod(org.codehaus.groovy.ast.ClassNode classNode, org.codehaus.groovy.ast.MethodNode declaredMethod)

    - #### protected boolean isStaticCandidateMethod(org.codehaus.groovy.ast.ClassNode classNode, org.codehaus.groovy.ast.MethodNode declaredMethod)

    - #### protected boolean isStaticMethodExcluded(org.codehaus.groovy.ast.ClassNode classNode, org.codehaus.groovy.ast.MethodNode declaredMethod)

    - #### protected boolean isStaticMethodIncluded(org.codehaus.groovy.ast.ClassNode classNode, org.codehaus.groovy.ast.MethodNode declaredMethod)

    - #### protected boolean isValidArtefactType()

    - #### private boolean isValidArtefactTypeByConvention(org.codehaus.groovy.ast.ClassNode classNode)

    - #### protected boolean isValidTargetClassNode(org.codehaus.groovy.ast.ClassNode classNode)

    - #### public void performInjection(org.codehaus.groovy.control.SourceUnit source, org.codehaus.groovy.classgen.GeneratorContext context, org.codehaus.groovy.ast.ClassNode classNode)

    - #### public void performInjection(org.codehaus.groovy.control.SourceUnit source, org.codehaus.groovy.ast.ClassNode classNode)

    - #### protected void performInjectionInternal(java.lang.String apiInstanceProperty, org.codehaus.groovy.control.SourceUnit source, org.codehaus.groovy.ast.ClassNode classNode)

      Subclasses can override to provide additional transformation

      Parameters:
        apiInstanceProperty
        `source` - The source
        `classNode` - The class node

    - #### @java.lang.Override public void performInjectionOnAnnotatedClass(org.codehaus.groovy.control.SourceUnit source, org.codehaus.groovy.ast.ClassNode classNode)

    - #### public void performInjectionOnAnnotatedClass(org.codehaus.groovy.control.SourceUnit source, org.codehaus.groovy.classgen.GeneratorContext context, org.codehaus.groovy.ast.ClassNode classNode)

    - #### protected void performInstanceImplementationInjection(org.codehaus.groovy.control.SourceUnit source, org.codehaus.groovy.ast.ClassNode classNode, java.util.Map<java.lang.String, org.codehaus.groovy.ast.ClassNode> genericsPlaceholders, java.lang.Class instanceImplementation)

    - #### protected void performStaticImplementationInjection(org.codehaus.groovy.ast.ClassNode classNode, java.util.Map<java.lang.String, org.codehaus.groovy.ast.ClassNode> genericsPlaceholders, java.lang.Class staticImplementation)

    - #### protected org.codehaus.groovy.ast.MethodNode populateAutowiredApiLookupMethod(org.codehaus.groovy.ast.ClassNode classNode, org.codehaus.groovy.ast.ClassNode implementationNode, java.lang.String apiProperty, java.lang.String methodName, org.codehaus.groovy.ast.stmt.BlockStatement methodBody)

    - #### protected org.codehaus.groovy.ast.MethodNode populateDefaultApiLookupMethod(org.codehaus.groovy.ast.ClassNode implementationNode, java.lang.String apiInstanceProperty, java.lang.String methodName, org.codehaus.groovy.ast.stmt.BlockStatement methodBody)

    - #### protected boolean requiresAutowiring()

      If the API requires autowiring then a

      Autowired:
        property will be added. If not a private field that instantiates the API will be crated. Defaults to true.
      Returns:
        Whether autowiring is required

    - #### protected boolean requiresStaticLookupMethod()

      Subclasses should override in the instance API requires a static lookup method instead of autowiring. Defaults to false.

      Returns:
        Whether a static lookup method is used for the instance API

    - #### protected java.util.Map<java.lang.String, org.codehaus.groovy.ast.ClassNode> resolveGenericsPlaceHolders(org.codehaus.groovy.ast.ClassNode classNode)

    - #### protected boolean shouldSkipInjection(org.codehaus.groovy.ast.ClassNode classNode)