Reputation: 604
I am new to annotations, i have classes annotated with custom annotation FXMLController
, send these classes to a factory to get the value from the annotation, but it is always null ~
annotation :
public @interface FXMLController {
String value() default "";
}
usage :
@FXMLController(value=CommonConstants.SPLASH_SCREEN)
public class SplashScreenController{ ....... )
getting the value :
Annotation annotation = controller.getAnnotation(FXMLController.class);
FXMLController fxmlController = (FXMLController) annotation;
Upvotes: 1
Views: 373
Reputation: 115328
I guess that you forgot to mark your annotation as @Retention(RetentionPolicy.RUNTIME)
EDIT: In fact your annotation should look like:
@Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Documentedpublic @interface FXMLController {
String value() default "";
}
Upvotes: 8