|
Groovy 1.8.5 | |||||||
FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectgroovy.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.Field Summary | |
---|---|
protected static ClassNode |
constrainedClassNode
|
protected ClassNode |
vcsClassNode
|
Fields inherited from class BindableASTTransformation | |
---|---|
boundClassNode, pcsClassNode |
Method Summary | |
---|---|
protected void
|
addVetoableChangeSupport(ClassNode declaringClass)
Adds the necessary field and methods to support vetoable change support. |
protected Statement
|
createConstrainedStatement(PropertyNode propertyNode, Expression fieldExpression)
Creates a statement body similar to:
|
protected Statement
|
createSetStatement(Expression fieldExpression)
Creates a statement body similar to:
|
protected void
|
createSetterMethod(ClassNode declaringClass, PropertyNode propertyNode, 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)
Snoops through the declaring class and all parents looking for a field of type VetoableChangeSupport. |
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 Object | |
---|---|
wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll |
Field Detail |
---|
protected static ClassNode constrainedClassNode
protected ClassNode vcsClassNode
Method Detail |
---|
protected void addVetoableChangeSupport(ClassNode declaringClass)
"protected final java.beans.VetoableChangeSupport this$vetoableChangeSupport = new java.beans.VetoableChangeSupport(this)"
Also adds support methods:
public void addVetoableChangeListener(java.beans.VetoableChangeListener)
public void addVetoableChangeListener(String, java.beans.VetoableChangeListener)
public void removeVetoableChangeListener(java.beans.VetoableChangeListener)
public void removeVetoableChangeListener(String, java.beans.VetoableChangeListener)
public java.beans.VetoableChangeListener[] getVetoableChangeListeners()
declaringClass
- the class to which we add the support field and methods
protected Statement createConstrainedStatement(PropertyNode propertyNode, Expression fieldExpression)
this.fireVetoableChange("field", field, field = value)
propertyNode
- the field node for the propertyfieldExpression
- a field expression for setting the property value
protected Statement createSetStatement(Expression fieldExpression)
field = value
.
Used when the field is not also
protected void createSetterMethod(ClassNode declaringClass, PropertyNode propertyNode, String setterName, Statement setterBlock)
declaringClass
- the class to which we will add the setterpropertyNode
- the field to back the settersetterName
- the name of the settersetterBlock
- the statement representing the setter block
public static boolean hasVetoableAnnotation(AnnotatedNode node)
node
- the node to check
protected boolean needsVetoableChangeSupport(ClassNode declaringClass, SourceUnit sourceUnit)
declaringClass
- the class to search
public void visit(ASTNode[] nodes, SourceUnit source)
nodes
- the AST nodessource
- the source unit for the nodes
Copyright © 2003-2011 The Codehaus. All rights reserved.