I'd like to create an "reload" setter for a property, that I'd like to keep in a trait. Then any subclasses that implement the trait would use their own getter, but the trait's setter. I don't want to add any extra annotations to existing properties. Here's a clarification:
trait Tr {
abstract String getS()
void setS(String value) {
((GroovyObject) this).setProperty('s', value)
reloadOnSChange()
}
void reloadOnSChange() {
// do something when S is changed
}
}
class Cl implements Tr {
String s
}
Cl cl = new Cl()
cl.s = 'hello world' // reloadOnSChange should be called
Is such a property listener possible?