public @interface MyAnnotation {
String value();
int count() default 0;
}
@MyAnnotation(value = "example", count = 10)
public class MyClass {
}
Class<MyClass> clazz = MyClass.class;
MyAnnotation annotation = clazz.getAnnotation(MyAnnotation.class);
if (annotation != null) {
String value = annotation.value();
int count = annotation.count();
}
<dependencies>
<dependency>
<groupId>jakarta.annotation</groupId>
<artifactId>jakarta.annotation-api</artifactId>
<version>2.0.0</version>
</dependency>
</dependencies>