Groovy Documentation

## groovy.beans
[Java] Class VetoableASTTransformation

    java.lang.Object
      groovy.beans.BindableASTTransformation
          groovy.beans.VetoableASTTransformation

    @GroovyASTTransformation(phase = CompilePhase.CANONICALIZATION)
    public class VetoableASTTransformation
    extends BindableASTTransformation

Handles generation of code for the `@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.

Authors:
  Danno Ferrin (shemnon)
  Chris Reeves

Field Summary
`protected static ClassNode` | `constrainedClassNode`
`protected ClassNode` | `vcsClassNode`

Fields inherited from class BindableASTTransformation
boundClassNode, pcsClassNode

Method Summary
`protected void` | `addVetoableChangeSupport(ClassNode declaringClass)`
`protected Statement` | `createConstrainedStatement(PropertyNode propertyNode, Expression fieldExpression)` Creates a statement body similar to: `this.fireVetoableChange("field", field, field = value)`
`protected Statement` | `createSetStatement(Expression fieldExpression)` Creates a statement body similar to: `field = value`.
`protected void` | `createSetterMethod(ClassNode declaringClass, PropertyNode propertyNode, java.lang.String setterName, Statement setterBlock)` Creates a setter method with the given body.
`static boolean` | `hasVetoableAnnotation(AnnotatedNode node)` Convenience method to see if an annotated node is `@Vetoable`.
`protected boolean` | `needsVetoableChangeSupport(ClassNode declaringClass, SourceUnit sourceUnit)`
`void` | `visit(ASTNode[] nodes, SourceUnit source)` Handles the bulk of the processing, mostly delegating to other methods.

Methods inherited from class BindableASTTransformation
addPropertyChangeSupport, createBindableStatement, createSetterMethod, hasBindableAnnotation, needsPropertyChangeSupport, visit

Methods inherited from 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

### constrainedClassNode

    protected static ClassNode constrainedClassNode

### vcsClassNode

    protected ClassNode vcsClassNode

Method Detail

### addVetoableChangeSupport

    protected void addVetoableChangeSupport(ClassNode declaringClass)

### createConstrainedStatement

    protected Statement createConstrainedStatement(PropertyNode propertyNode, Expression fieldExpression)

  Creates a statement body similar to: `this.fireVetoableChange("field", field, field = value)`
  Parameters:
    `propertyNode` - the field node for the property
    `fieldExpression` - a field expression for setting the property value
  Returns:
    the created statement

### createSetStatement

    protected Statement createSetStatement(Expression fieldExpression)

  Creates a statement body similar to: `field = value`.

  Used when the field is not also
  Bindable:
    @param fieldExpression a field expression for setting the property value
  Returns:
    the created statement

### createSetterMethod

    protected void createSetterMethod(ClassNode declaringClass, PropertyNode propertyNode, java.lang.String setterName, Statement setterBlock)

  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
  Parameters:
    `declaringClass` - the class to which we will add the setter
    `propertyNode` - the field to back the setter
    `setterName` - the name of the setter
    `setterBlock` - the statement representing the setter block

### hasVetoableAnnotation

    public static boolean hasVetoableAnnotation(AnnotatedNode node)

  Convenience method to see if an annotated node is `@Vetoable`.
  Parameters:
    `node` - the node to check
  Returns:
    true if the node is constrained

### needsVetoableChangeSupport

    protected boolean needsVetoableChangeSupport(ClassNode declaringClass, SourceUnit sourceUnit)

### visit

    public void visit(ASTNode[] nodes, SourceUnit source)

  Handles the bulk of the processing, mostly delegating to other methods.
  Parameters:
    `nodes` - the AST nodes
    `source` - the source unit for the nodes

Groovy Documentation