Repeatable annotations

Annotate the declaration of the annotation with @Repeatable to denote that the annotation can be applied multiple times at one place. The parameter to this annotation is an annotation type that should have a parameter of type, which is an array of this annotation. Don't try to understand! I'll give an example instead. I already have, in fact—we have @PoweredDevices. It has an argument that is an array of @ParameteredPoweredDevice. Consider that we now annotate this @interface as the following:

... 
@Repeatable(PoweredDevices.class) 
public @interface ParameteredPoweredDevice { 
...

Then, we can simplify the use of @ParameteredPoweredDevice. We can repeat the annotation multiple times, and the Java runtime will automatically ...

Get Java Projects - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.