Top Description Fields Constructors Methods
org.codehaus.groovy.transform

public Class ImmutableASTTransformation

extends AbstractASTTransformation
implements CompilationUnitAware
Class Inheritance
All Implemented Interfaces
groovy.transform.CompilationUnitAware
Annotations
@GroovyASTTransformation
phase:CANONICALIZATION
Imports
groovy.lang.GroovyClassLoader, .MetaClass, .MissingPropertyException, groovy.transform.CompilationUnitAware, .ImmutableBase, groovy.transform.options.PropertyHandler, org.apache.groovy.ast.tools.ImmutablePropertyUtils, org.codehaus.groovy.ast.ASTNode, .AnnotatedNode, .AnnotationNode, .ClassHelper, .ClassNode, .FieldNode, .Parameter, .PropertyNode, .VariableScope, org.codehaus.groovy.ast.expr.ConstantExpression, org.codehaus.groovy.ast.stmt.BlockStatement, .Statement, org.codehaus.groovy.control.CompilationUnit, .CompilePhase, .SourceUnit, org.codehaus.groovy.runtime.DefaultGroovyMethods, .InvokerHelper, java.lang.annotation.Annotation, java.lang.reflect.Field, java.util.ArrayList, .Collection, .HashMap, .List, .Map

Handles generation of code for the @Immutable annotation.

Field Summary

Modifier and TypeField and Description
private CompilationUnit
private static final String
private static final ClassNode
public static final String
private static final String
private static final Class<? extends Annotation>
public static final ClassNode
private static final String
Inherited from org.codehaus.groovy.transform.AbstractASTTransformation:
RETENTION_CLASSNODEsourceUnit

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private static void
private static void
public static Object
checkImmutable(String className, String fieldName, Object field)

This method exists to be binary compatible with 1.7 - 1.8.6 compiled code.

public static Object
checkImmutable(Class<?> clazz, String fieldName, Object field)

For compatibility with pre 2.5 compiled classes

public static Object
checkImmutable(Class<?> clazz, String fieldName, Object field, List<String> knownImmutableFieldNames, List<Class<T>> knownImmutableClasses)

public static void
private static Statement
private static void
createCopyWith(final ClassNode cNode, final List<PropertyNode> pList)

private void
private static void
private static Annotation
public String
getAnnotationName()

Overrides org.codehaus.groovy.transform.AbstractASTTransformation.getAnnotationName.

If the transform is associated with a single annotation, returns a name suitable for displaying in error messages.
pack-priv static boolean
isSpecialNamedArgCase(List<PropertyNode> list, boolean checkSize)

private static void
pack-priv static boolean
public void
private boolean
public void
visit(ASTNode[]
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.
nodes
,
SourceUnit
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.
source
)

Implements org.codehaus.groovy.transform.ASTTransformation.visit.

The method is invoked when an AST Transformation is active.
Inherited from org.codehaus.groovy.transform.AbstractASTTransformation:
addErrorcheckIncludeExcludecheckIncludeExcludecheckIncludeExcludeUndefinedAwarecheckIncludeExcludeUndefinedAwarecheckNotInterfacecheckPropertyListcheckPropertyListcheckPropertyListcopyAnnotatedNodeAnnotationscopyAnnotatedNodeAnnotationsdeemedInternalNamegetClassListgetMemberClassListgetMemberClassValuegetMemberClassValuegetMemberIntValuegetMemberListgetMemberStringListgetMemberStringValuegetMemberStringValuegetMemberValuehasAnnotationinitmemberHasValuenonGenericshouldSkipshouldSkipshouldSkipOnDescriptorshouldSkipOnDescriptorUndefinedAwareshouldSkipUndefinedAwareshouldSkipUndefinedAwaretokenize

Field Detail

compilationUnitback to summary
private CompilationUnit compilationUnit
COPY_WITH_METHODback to summary
private static final String COPY_WITH_METHOD
HMAP_TYPEback to summary
private static final ClassNode HMAP_TYPE
IMMUTABLE_BREADCRUMBback to summary
public static final String IMMUTABLE_BREADCRUMB
MEMBER_ADD_COPY_WITHback to summary
private static final String MEMBER_ADD_COPY_WITH
MY_CLASSback to summary
private static final Class<? extends Annotation> MY_CLASS
MY_TYPEback to summary
public static final ClassNode MY_TYPE
MY_TYPE_NAMEback to summary
private static final String MY_TYPE_NAME

Constructor Detail

ImmutableASTTransformationback to summary
public ImmutableASTTransformation()

Method Detail

addPropertyback to summary
private static void addProperty(ClassNode cNode, PropertyNode pNode)
adjustPropertyForImmutabilityback to summary
private static void adjustPropertyForImmutability(PropertyNode pNode, List<PropertyNode> newNodes, PropertyHandler handler)
checkImmutableback to summary
public static Object checkImmutable(String className, String fieldName, Object field)

This method exists to be binary compatible with 1.7 - 1.8.6 compiled code.

Annotations
@SuppressWarnings:Unchecked
checkImmutableback to summary
public static Object checkImmutable(Class<?> clazz, String fieldName, Object field)

For compatibility with pre 2.5 compiled classes

Annotations
@SuppressWarnings:Unchecked
checkImmutableback to summary
public static Object checkImmutable(Class<?> clazz, String fieldName, Object field, List<String> knownImmutableFieldNames, List<Class<T>> knownImmutableClasses)
Annotations
@SuppressWarnings:Unchecked
checkPropNamesback to summary
public static void checkPropNames(Object instance, Map<String, Object> args)
createCheckForPropertyback to summary
private static Statement createCheckForProperty(final PropertyNode pNode)
createCopyWithback to summary
private static void createCopyWith(final ClassNode cNode, final List<PropertyNode> pList)
doMakeImmutableback to summary
private void doMakeImmutable(ClassNode cNode, AnnotationNode node, PropertyHandler handler)
ensureNotPublicback to summary
private static void ensureNotPublic(AbstractASTTransformation xform, String cNode, FieldNode fNode)
getAnnotationByNameback to summary
private static Annotation getAnnotationByName(Object field, String name)
getAnnotationNameback to summary
public String getAnnotationName()

Overrides org.codehaus.groovy.transform.AbstractASTTransformation.getAnnotationName.

Doc from org.codehaus.groovy.transform.AbstractASTTransformation.getAnnotationName.

If the transform is associated with a single annotation, returns a name suitable for displaying in error messages.

Returns:String

The simple name of the annotation including the "@" or null if no such name is defined

Annotations
@Override
isSpecialNamedArgCaseback to summary
pack-priv static boolean isSpecialNamedArgCase(List<PropertyNode> list, boolean checkSize)
makeClassFinalback to summary
private static void makeClassFinal(AbstractASTTransformation xform, ClassNode cNode)
makeImmutableback to summary
pack-priv static boolean makeImmutable(ClassNode cNode)
setCompilationUnitback to summary
public void setCompilationUnit(CompilationUnit unit)

Implements groovy.transform.CompilationUnitAware.setCompilationUnit.

Annotations
@Override
unsupportedTupleAttributeback to summary
private boolean unsupportedTupleAttribute(AnnotationNode anno, String memberName)
visitback to summary
public void visit(ASTNode[] nodes, SourceUnit source)

Implements org.codehaus.groovy.transform.ASTTransformation.visit.

Doc from org.codehaus.groovy.transform.ASTTransformation.visit.

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.

Parameters
nodes:ASTNode[]

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:SourceUnit

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.