@Vetoable annotation, and @Bindable
if also present.
Generally, it adds (if needed) a VetoableChangeSupport field and the needed add/removeVetoableChangeListener methods to support the listeners.
It also generates the setter and wires the setter through the VetoableChangeSupport.
If a Bindable annotation is detected it also adds support similar
to what BindableASTTransformation would do.
| Modifier and Type | Field and Description |
|---|---|
| protected static final ClassNode |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| private void | addListenerToClass(SourceUnit source, ClassNode classNode)
Hides groovy. |
| private void | |
| protected void | addVetoableChangeSupport(ClassNode
the class to which we add the support field and methods declaringClass)Adds the necessary field and methods to support vetoable change support. |
| protected Statement | Returns: the created statementthe field node for the property propertyNode, Expression a field expression for setting the property value fieldExpression)Creates a statement body similar to:
|
| private void | createListenerSetter(SourceUnit source, boolean bindable, ClassNode declaringClass, PropertyNode propertyNode)
|
| protected Statement | Returns: the created statementa field expression for setting the property value fieldExpression)Creates a statement body similar to:
|
| protected void | createSetterMethod(ClassNode
the class to which we will add the setter declaringClass, PropertyNode the field to back the setter propertyNode, String the name of the setter setterName, Statement the statement representing the setter block setterBlock)Overrides groovy. |
| public static boolean | Returns: true if the node is constrainedthe node to check node)Convenience method to see if an annotated node is |
| protected boolean | Returns: true if vetoable change support should be addedthe class to search declaringClass, SourceUnit sourceUnit)Snoops through the declaring class and all parents looking for a field of type VetoableChangeSupport. |
| public void | visit(ASTNode[]
the AST nodes nodes, SourceUnit the source unit for the nodes source)Overrides groovy. Implements org. |
| private static void | wrapSetterMethod(ClassNode classNode, boolean bindable, String propertyName)
Wrap an existing setter. |
| constrainedClassNode | back to summary |
|---|---|
| protected static final ClassNode constrainedClassNode | |
| VetoableASTTransformation | back to summary |
|---|---|
| public VetoableASTTransformation() | |
| addListenerToClass | back to summary |
|---|---|
| private void addListenerToClass(SourceUnit source, ClassNode classNode) Hides groovy. | |
| addListenerToProperty | back to summary |
|---|---|
| private void addListenerToProperty(SourceUnit source, AnnotationNode node, AnnotatedNode parent) | |
| addVetoableChangeSupport | back to summary |
|---|---|
| protected void addVetoableChangeSupport(ClassNode declaringClass) Adds the necessary field and methods to support vetoable change support.
Adds a new field:
Also adds support methods:
| |
| createConstrainedStatement | back to summary |
|---|---|
| protected Statement createConstrainedStatement(PropertyNode propertyNode, Expression fieldExpression) Creates a statement body similar to:
| |
| createListenerSetter | back to summary |
|---|---|
| private void createListenerSetter(SourceUnit source, boolean bindable, ClassNode declaringClass, PropertyNode propertyNode) | |
| createSetStatement | back to summary |
|---|---|
| protected Statement createSetStatement(Expression fieldExpression) Creates a statement body similar to:
Used when the field is not also
| |
| createSetterMethod | back to summary |
|---|---|
| protected void createSetterMethod(ClassNode declaringClass, PropertyNode propertyNode, String setterName, Statement setterBlock) Overrides groovy. Creates a setter method with the given body. This differs from normal setters in that we need to add a declared exception java.beans.PropertyVetoException
| |
| hasVetoableAnnotation | back to summary |
|---|---|
| public static boolean hasVetoableAnnotation(AnnotatedNode node) Convenience method to see if an annotated node is
| |
| needsVetoableChangeSupport | back to summary |
|---|---|
| protected boolean needsVetoableChangeSupport(ClassNode declaringClass, SourceUnit sourceUnit) Snoops through the declaring class and all parents looking for a field of type VetoableChangeSupport. Remembers the field and returns false if found otherwise returns true to indicate that such support should be added.
| |
| visit | back to summary |
|---|---|
| public void visit(ASTNode[] nodes, SourceUnit source) Overrides groovy. Implements org. Handles the bulk of the processing, mostly delegating to other methods.
| |
| wrapSetterMethod | back to summary |
|---|---|
| private static void wrapSetterMethod(ClassNode classNode, boolean bindable, String propertyName) Wrap an existing setter. | |