Generate a Constant expression from a function

Posted by Lee on Stack Overflow See other posts from Stack Overflow or by Lee
Published on 2010-06-11T20:57:22Z Indexed on 2010/06/11 21:03 UTC
Read the original article Hit count: 187

Filed under:
|

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.

© Stack Overflow or respective owner

Related posts about java

Related posts about google-wave