public class LegacyHashMapPropertyHandler
extends ImmutablePropertyHandler
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 provides 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.
| Fields inherited from class | Fields |
|---|---|
class PropertyHandler |
PROPERTY_OPTIONS_TYPE |
| Type Params | Return Type | Name and description |
|---|---|---|
|
public Statement |
createPropInit(AbstractASTTransformation xform, AnnotationNode anno, ClassNode cNode, PropertyNode pNode, Parameter namedArgsMap)* * Create a statement that will initialize the property including any defensive copying. * Return null to indicate that no initialization statement should be emitted
* for this property; this is distinct from returning an empty block and skips the
* corresponding entry in the generated constructor body altogether.
*
*
|
|
public boolean |
validateAttributes(AbstractASTTransformation xform, AnnotationNode anno)* * Validates annotation attributes supported by this handler. * *
|
|
public boolean |
validateProperties(AbstractASTTransformation xform, BlockStatement body, ClassNode cNode, List<PropertyNode> props)* * Validates the properties selected for processing. * *
|
| Methods inherited from class | Name |
|---|---|
class ImmutablePropertyHandler |
checkFinalArgNotOverridden, cloneCollectionExpr, createAsImmutableX, createConstructorStatement, createPropGetter, createPropInit, createPropSetter, validateAttributes, validateProperties |
class PropertyHandler |
createPropGetter, createPropInit, createPropSetter, createPropertyHandler, isValidAttribute, validateAttributes, validateProperties |
*
* Create a statement that will initialize the property including any defensive copying.
* Return null to indicate that no initialization statement should be emitted
* for this property; this is distinct from returning an empty block and skips the
* corresponding entry in the generated constructor body altogether.
*
*
xform - the transform being processed
*anno - the annotation node
*cNode - the classnode containing the property
*pNode - the property node to initialize
*namedArgsMap - an "args" Map if the property value should come from a named arg map or null if not* * Validates annotation attributes supported by this handler. * *
xform - the active transform
*anno - the property options annotation
*true if validation succeeds* * Validates the properties selected for processing. * *
xform - the active transform
*body - the statement block being generated
*cNode - the owning class
*props - the candidate properties
*true if validation succeeds