L
levente.meszaros
Hi,
I don't know much about AspectJ, but I'm wondering about something in
Java like this one at http://common-lisp.net/project/computed-class.
Is it possible to write some AspectJ code (and add some pointcuts,
etc.) to
transform:
public Integer a;
into:
private ComputedState<Integer> aState = new
ComputedState<Integer>();
public Integer getA() {
return aState.getValue();
}
public void setA(int a) {
aState.setValue(a);
}
and transform:
public Integer getB() {
return getA() + 1;
}
into:
private ComputedState<Integer> bState;
public int getB() {
return bState.recomputeIfInvalidAs(new IComputation() {
public Object compute() {
return getA() + 1;
}
});
}
The rest is simple and could be done in Java too and may eliminate
lots of listeners...
levy
I don't know much about AspectJ, but I'm wondering about something in
Java like this one at http://common-lisp.net/project/computed-class.
Is it possible to write some AspectJ code (and add some pointcuts,
etc.) to
transform:
public Integer a;
into:
private ComputedState<Integer> aState = new
ComputedState<Integer>();
public Integer getA() {
return aState.getValue();
}
public void setA(int a) {
aState.setValue(a);
}
and transform:
public Integer getB() {
return getA() + 1;
}
into:
private ComputedState<Integer> bState;
public int getB() {
return bState.recomputeIfInvalidAs(new IComputation() {
public Object compute() {
return getA() + 1;
}
});
}
The rest is simple and could be done in Java too and may eliminate
lots of listeners...
levy