@Retention(value=SOURCE)
@Target(value={FIELD,TYPE})
public @interface PropertyListener
Annotates a property.
This transformation provides a convenient way to register PropertyChangeListeners on an observable bean by leveraging Groovy's closures and the Groovy cast operator.
The following code exemplifies what must be written by hand in order to register a pair of PropertyChangeListeners. One of them is a catch-all handler while the second is property specific.
import griffon.transform.Observable import java.beans.PropertyChangeListener class MyModel { @Observable String name @Observable String lastname def snoopAll = { evt -> ... } MyModel() { addPropertyChangeListener(snoopAll as PropertyChangeListener) addPropertyChangeListener('lastname', { controller.someAction(it) } as PropertyChangeListener) } }
Applying @PropertyListener to the previous snippet results in the following code
import griffon.transform.PropertyListener import griffon.transform.Observable @PropertyListener(snoopAll) class MyModel { @Observable String name @Observable @PropertyListener({controller.someAction(it)}) String lastname def snoopAll = { evt -> ... } }Any closures found as the annotation's value will be either transformed into inner classes that implement PropertyChangeListener (when the value is a closure defined in place) or be casted as a proxy of PropertyChangeListener (when the value is a property reference found in the same class).
List of closures are also supported.
Modifier and Type | Required Element and Description |
---|---|
java.lang.String |
value |