For my Google Wave robot, on the onDocumentChanged event I want to apply a filter as follows:
@Capability(filter = FILTER)
@Override
public void onDocumentChanged(DocumentChangedEvent event) {
...
}
I want the filter to be generated the first time the robot is run, which I'm trying to do as follows:
private static final String FILTER = generateFilter();
private static final String generateFilter(){
...
}
However, it complains FILTER isn't a constant expression when used within @Capability.
generateFilter() will return the same string every time it is called, I'm only using it to create the string so that when I make changes, I don't need to worry about updating the filter.
Now I could be going about this all wrong, so wondered if anyone knew what I'm doing wrong, or knew a better way in which I could generate a constant expression from the function.
I'm unfamiliar with Google Wave, but a static initializer might be acceptable, as shown here and outlined below.
private static final String FILTER;
static { FILTER = "..."; }
Addendum: On closer scrutiny, this approach is not possible, as an annotation value must be (among other things) a constant expression.