Reputation: 2420
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;
Upvotes: 4
Views: 4919
Reputation: 2420
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
Upvotes: 3