I have these annotations:
@interface NotNull {
boolean value() default false;
}
@interface Type {
Class<?> value();
}
and then I use them with an enum:
public enum KeyMap implements IMapEnum {
@Type(Integer.class)
@NotNull
USER_ID("user_id", "userId"),
@NotNull
USER_HANDLE("user_handle", "userHandle"),
@NotNull
USER_EMAIL("user_email", "userEmail");
private String key;
private String value;
KeyMap(String k, String v) {
this.key = k;
this.value = v;
}
@Override
public String getKey() {
return this.key;
}
@Override
public String getValue() {
return this.value;
}
}
my question is - how do I retrieve the value of the annotation for each instance of the enum? The interface being implemented is simple and is not really part of the question:
public interface IMapEnum {
String getKey();
String getValue();
}
but maybe someone can show how to retrieve the annotations in either getKey
or getValue
method?