Not sure whether the title is misleading, but requirement is below.
I need to use a string value as input to a custom annotation. When use an enum value, the IDE gives
java attribute value must be constant.
@test("test") // works
@test(Const.myEnum.test.toString()) //java attribute value must be constant
I read about the importance of the string value being immutable. Is it possible to achive through enum (not the public static final String hack).
thanks.
If the annotation is within your control, make the attribute type be an
enumtype instead ofString. Otherwise it is not possible.Also, the annotation, as every java class, should start with upper-case (i.e.
Test, nottest):