Top Description Fields Constructors Methods
groovy.transform.options

public Class LegacyHashMapPropertyHandler

extends ImmutablePropertyHandler
Class Inheritance
Imports
org.codehaus.groovy.ast.AnnotationNode, .ClassNode, .FieldNode, .Parameter, .PropertyNode, org.codehaus.groovy.ast.expr.ConstantExpression, .Expression, org.codehaus.groovy.ast.stmt.BlockStatement, .Statement, org.codehaus.groovy.transform.AbstractASTTransformation, .TupleConstructorASTTransformation, java.util.HashMap, .List

The @Immutable transformation in earlier versions of Groovy tried to be smart in the case of an immutable class with a single HashMap property, the supplied Map constructor tried to be compatible with both expected tuple behavior and expected named-argument behavior by peeking into the supplied map and guessing as to which approach might be applicable. Recent versions of Groovy now allow both @TupleConstructor and @MapConstructor annotations to co-exist which provide's a more flexible solution to this problem. While more flexible, the new approach isn't fully compatible with the previous approach. If for some reason you need the old behavior, you can try this property handler. Some features of the new approach won't be available to you.
Since
2.5.0

Field Summary

Modifier and TypeField and Description
private static final ClassNode

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private Statement
public Statement
createPropInit(AbstractASTTransformation
the transform being processed
xform
,
AnnotationNode
the '@ImmutableBase' annotation node
anno
,
ClassNode
the classnode containing the property
cNode
,
PropertyNode
the property node to initialize
pNode
,
Parameter
an "args" Map if the property value should come from a named arg map or null if not
namedArgsMap
)

Overrides groovy.transform.options.ImmutablePropertyHandler.createPropInit.

Create a statement that will initialize the property including any defensive copying.
public boolean
public boolean
Inherited from groovy.transform.options.ImmutablePropertyHandler:
checkFinalArgNotOverriddencloneCollectionExprcreateAsImmutableXcreateConstructorStatementcreateConstructorStatementcreatePropGettercreatePropSetter

Field Detail

HMAP_TYPEback to summary
private static final ClassNode HMAP_TYPE

Constructor Detail

LegacyHashMapPropertyHandlerback to summary
public LegacyHashMapPropertyHandler()

Method Detail

createLegacyConstructorStatementMapSpecialback to summary
private Statement createLegacyConstructorStatementMapSpecial(FieldNode fNode)
createPropInitback to summary
public Statement createPropInit(AbstractASTTransformation xform, AnnotationNode anno, ClassNode cNode, PropertyNode pNode, Parameter namedArgsMap)

Overrides groovy.transform.options.ImmutablePropertyHandler.createPropInit.

Doc from groovy.transform.options.PropertyHandler.createPropInit.

Create a statement that will initialize the property including any defensive copying. Null if no statement should be added.

Parameters
xform:AbstractASTTransformation

the transform being processed

anno:AnnotationNode

the '@ImmutableBase' annotation node

cNode:ClassNode

the classnode containing the property

pNode:PropertyNode

the property node to initialize

namedArgsMap:Parameter

an "args" Map if the property value should come from a named arg map or null if not

Annotations
@Override
validateAttributesback to summary
public boolean validateAttributes(AbstractASTTransformation xform, AnnotationNode anno)

Overrides groovy.transform.options.ImmutablePropertyHandler.validateAttributes.

Annotations
@Override
validatePropertiesback to summary
public boolean validateProperties(AbstractASTTransformation xform, BlockStatement body, ClassNode cNode, List<PropertyNode> props)

Overrides groovy.transform.options.ImmutablePropertyHandler.validateProperties.

Annotations
@Override