Can annotation have complex return type, such as HashMap.
I am looking for something like:
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public @interface column {
public HashMap<String, String> table();
}
so I can have a constant annotated like(pseudo code):
@column({table=(dbName, tableName), table=(dbName, tableName2)})
public static final String USER_ID = "userid";
If Annotation doesn’t allow you to have complex return type, then any good practice for this kind of case?
No, annotation elements can only be primitive types, Strings,
enumtypes,Class, other annotations, or arrays of any of these. The typical way to represent these kinds of structures would be to declare another annotation typethen say
And use the annotation as