stefan-oehme/xtend-annotations — pull request #3 by rzymek (2013-05-08 17:16:23+00:00)
Title: @FiresEvent

Generates methods for registering listeners and notifying them.

@FiresEvent(typeof(ChangeListener))
class TextBox {
}

becomes:

@FiresEvent(typeof(ChangeListener))
class TextBox {
val List _changeListeners = new ArrayList
protected def fireStateChanged(ChangeEvent e) {
_changeListeners.forEach [
it.stateChanged(e);
]
}
def addChangeListener(ChangeListener listener) {
_changeListeners.add(listener);
}
def removeChangeListener(ChangeListener listener) {
_changeListeners.remove(listener);
}
}

Full example at https://github.com/rzymek/xtend-annotations/blob/FiresEvent/xtend-annotations-example/src/main/java/de/oehme/xtend/annotation/example/TextBox.xtend