@GroovyASTTransformation(phase= CompilePhase.CANONICALIZATION) public class BindableASTTransformation extends Object
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Modifiers | Name | Description |
---|---|---|
protected static ClassNode |
boundClassNode |
Type | Name and description |
---|---|
protected void |
addPropertyChangeSupport(ClassNode declaringClass) Adds the necessary field and methods to support property change support. |
protected Statement |
createBindableStatement(PropertyNode propertyNode, Expression fieldExpression) Creates a statement body similar to: this.firePropertyChange("field", field, field = value) |
protected void |
createSetterMethod(ClassNode declaringClass, PropertyNode propertyNode, String setterName, Statement setterBlock) Creates a setter method with the given body. |
static boolean |
hasBindableAnnotation(AnnotatedNode node) Convenience method to see if an annotated node is @Bindable . |
protected boolean |
needsPropertyChangeSupport(ClassNode declaringClass, SourceUnit sourceUnit) Snoops through the declaring class and all parents looking for methods void addPropertyChangeListener(PropertyChangeListener) ,
void removePropertyChangeListener(PropertyChangeListener) , and
void firePropertyChange(String, Object, Object) . |
void |
visit(ASTNode[] nodes, SourceUnit source) Handles the bulk of the processing, mostly delegating to other methods. |
Adds the necessary field and methods to support property change support.
Adds a new field:
protected final java.beans.PropertyChangeSupport this$PropertyChangeSupport = new java.beans.PropertyChangeSupport(this)
"
Also adds support methods:
public void addPropertyChangeListener(java.beans.PropertyChangeListener)
public void addPropertyChangeListener(String, java.beans.PropertyChangeListener)
public void removePropertyChangeListener(java.beans.PropertyChangeListener)
public void removePropertyChangeListener(String, java.beans.PropertyChangeListener)
public java.beans.PropertyChangeListener[] getPropertyChangeListeners()
declaringClass
- the class to which we add the support field and methods Creates a statement body similar to:
this.firePropertyChange("field", field, field = value)
propertyNode
- the field node for the propertyfieldExpression
- a field expression for setting the property valueCreates a setter method with the given body.
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 Convenience method to see if an annotated node is @Bindable
.
node
- the node to check Snoops through the declaring class and all parents looking for methods
void addPropertyChangeListener(PropertyChangeListener)
,
void removePropertyChangeListener(PropertyChangeListener)
, and
void firePropertyChange(String, Object, Object)
. If any are defined all
must be defined or a compilation error results.
declaringClass
- the class to searchsourceUnit
- the source unit, for error reporting. @NotNull
.Handles the bulk of the processing, mostly delegating to other methods.
nodes
- the ast nodessource
- the source unit for the nodes