Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to restrict the type of field for a Java annotation?

It's possible to restrict an Java annotation to fields, methods, etc.

But, how about a field or a method name or type?

For, example, I would like to create an annotation that can be put only in fields of the type long and with name id;

like image 878
Natanael Avatar asked Oct 15 '25 03:10

Natanael


1 Answers

It possible using an Annotation Processor.

Some tutorials that may help in this task:

http://deors.wordpress.com/2011/10/08/annotation-processors/

http://java.dzone.com/news/using-java-6-processors

like image 172
Natanael Avatar answered Oct 17 '25 17:10

Natanael



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!