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

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -