java - Access annotated fields -
i made custom annotation project used fields,
@myannotation int myvariable
i have class in charge of performing actions according variables values.the project has undetermined number of classes annotations included. how can access them using annotations processor in order access values?
i can check annotated variables going though each class, not modifying value since not object.
any suggestion on how it?
thanks in advance!! :)
int getmyvariable(foo foo) throws illegalargumentexception, illegalaccessexception{ for(field f:foo.getclass().getdeclaredfields()){ /** * ensure retentionpolicy of 'myannotation' runtime. */ if(f.isannotationpresent(myannotation.class)){ return f.getint(foo); } } return -1; }
Comments
Post a Comment