/** * Matches an {@link AnnotationSource} to declare any annotation * that matches the given matcher. Note that this matcher does not match inherited annotations that only exist * for types. Use {@link net.bytebuddy.matcher.ElementMatchers#inheritsAnnotation(net.bytebuddy.matcher.ElementMatcher)} * for matching inherited annotations. * * @param matcher A matcher to apply on any declared annotation of the matched annotated element. * @param <T> The type of the matched object. * @return A matcher that validates that an annotated element is annotated with an annotation that matches * the given {@code matcher}. */ public static <T extends AnnotationSource> ElementMatcher.Junction<T> declaresAnnotation(ElementMatcher<? super AnnotationDescription> matcher) { return new DeclaringAnnotationMatcher<T>(new CollectionItemMatcher<AnnotationDescription>(matcher)); }