Annotation on enum constant.
I want to add annotations to some of the constants like in the code below.
Code :
public enum Material {
@NonBuyable
@NonSellable
AIR(0),
Then I'm trying to check if it is present with this
Code :
if(!Material.class.getField(m.name()).isAnnotationPresent(NonBuyable.class))
{
// do something...
}
Since it never worked I tried to get all the annotations for the given constant, but even if it had some, it didn't show up.
So do anyone have any idea of what I'm doing wrong?
Thanks in advance.