I have a Java annotation type like this:
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
@Retention(RUNTIME)
@Target(METHOD)
public @interface Foo {
}
My intention is to avoid multiple instances of this annotation. In other words I want to disallow the next example code and throw an exception:
public class FooTest {
@Foo
public void method1(){...}
@Foo
public void method2(){...}
}
Any suggestion?