I\'m attempting to slap two or more annotations of the same type on a single element, in this case, a method. Here\'s the approximate code that I\'m working with:
http://docs.oracle.com/javase/tutorial/java/annotations/repeating.html
Starting from Java8 you can describe repeatable annotations:
@Repeatable(FooValues.class)
public @interface Foo {
String bar();
}
public @interface FooValues {
Foo[] value();
}
Note, value
is required field for values list.
Now you can use annotations repeating them instead of filling the array:
@Foo(bar="one")
@Foo(bar="two")
public void haha() {}