/** * @param annot Annotation instance to match, or {@code null} to match only the lack of a qualifier. * @return A QualifierMatcher that matches annotations equaling annot */ public static QualifierMatcher match(@Nonnull Annotation annot) { if (annot == null) { return matchNone(); } else if (annot.annotationType().getDeclaredMethods().length == 0) { logger.debug("using type matcher for nullary annotation {}", annot); // Instances of the same nullary annotation are all equal to each other, so just do // type checking. This makes aliasing work with annotation value matchers, b/c we // do not allow aliases to have parameters. The matcher still has value priority. return new AnnotationClassMatcher(annot.annotationType(), DefaultMatcherPriority.MATCH_VALUE); } else { return new AnnotationMatcher(annot); } }
private Object readResolve() throws ObjectStreamException { try { return new AnnotationClassMatcher(type.resolve().asSubclass(Annotation.class)); } catch (ClassNotFoundException e) { InvalidObjectException ex = new InvalidObjectException("cannot resolve " + type); ex.initCause(e); throw ex; } catch (ClassCastException e) { InvalidObjectException ex = new InvalidObjectException("class " + type + " not an annotation"); ex.initCause(e); throw ex; } } }
/** * @param annotType Annotation type class to match; {@code null} to match only the lack of a * qualifier. * @return A QualifierMatcher that matches any annotation of the given class * type. */ public static QualifierMatcher match(Class<? extends Annotation> annotType) { if (annotType == null) { return matchNone(); } else { return new AnnotationClassMatcher(annotType); } }