Generate a Constant expression from a function
- by Lee
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.