Is it possible to restrict only annotations into a List? So let's say I have two annotations:
(1) Foo.class
(2) Bar.class
When declaring a List, I only want to allow the inclusion of annotations but everything else would result in a compilation error:
List<Something> list = new ArrayList<Something>();
list.add(Foo.class);
list.add(Bar.class);
list.add(String.class); // bad
If the above is even possible, is it then possible to restrict it to types of annotations? By that I mean only allow annotations that are grouped somehow. For example, if I have the following annotations:
(1) Shark.class
(2) GoldFish.class
(3) Lion.class
And I only want to allow annotations that live in the water. Therefore adding Lion.class to the List would result in a compilation error due to his land loving ways.