So I have a custom annotation
@Target({ElementType.METHOD, ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Inherited
@Documented
public @interface Intercepted {}
that I want to use to weave aspects into methods (AspectJ, @annotation(Intercepted)).
The idea is that I weave the aspect in when I annotate the method @Intercepted directly -- that part works -- or if I annotate the class, the aspect should be weaved into all its (public) methods -- that part doesn't.
Furthermore, if I annotate a class and one of its methods, the aspect should only get weaved in once, the method-level annotation overriding the class-level one.
Essentially, I want an "add the class-level annotation if there's a class-level annotation, but only if there isn't already a method-level annotation."
How do I do that?