0

I've got a couple of annotations, which share a common method

String code();

Now, in some generic code, I would like to have something like a common base annotation, that has the same common method. I am thinking about something like

public @interface BaseAnnotation {
    String code();
}

public @interface MyAnnotation extends BaseAnnotation {
}

so, that my generic code might include

BaseAnnotation ba = (BaseAnnotation) annotation;
String code = ba.code();

Is something like that possible?

Thanks

user1774051
  • 843
  • 1
  • 6
  • 18

0 Answers0