How do I pass string variable to an annotated class, where the String variable is present in a properties file?
I'm seeing the error message: The value for annotation attribute Example.localID must be a constant
For Example consider below annoated interface
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface Example {
String localID() default "";
}
I have created a class 'ExampleService' which is annotated with 'Example' interface as shown below
I like to provides values for localID as 'localID=Messages.TITLE' as shown below.
Currently this not possible to provides values like this because of compilation error, is there any way to solve this issue or alternative(I donot want to make final because values get changed depending on local) ?
'Messages.TITLE' values comes from property file.
@Example(localID=Messages.TITLE)
public class ExampleService {
}
class:Messages
public class Messages extends NLS {
public static String TITLE;
private static final String BUNDLE_NAME = "xyz"; //$NON-NLS-1$
static {
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
}
private Messages() {
}