Is it possible to restrict only annotations in a List? So, let's say I have two annotations:
(1) Foo.class
(2) Bar.class
When declaring a list, I want to enable the inclusion of annotations, but everything else will lead to a compilation error:
List<Something> list = new ArrayList<Something>();
list.add(Foo.class);
list.add(Bar.class);
list.add(String.class);
If possible, is it possible to limit it to the types of annotations? By this, I mean only allowing annotations that are somehow grouped. For example, if I have the following annotations:
(1) Shark.class
(2) GoldFish.class
(3) Lion.class
And I just want to allow annotations that live in water. Therefore, adding Lion.class to the List will result in a compilation error due to its earthly love paths.
source
share