@Test public void testFindOn() { Optional<MetaMarkerAnnotation> metaMarkerAnnotation = MetaAnnotation.of(MetaMarkerAnnotation.class) .findOn(annotatedAnnotation); assertThat(metaMarkerAnnotation.isPresent()); assertThat(metaMarkerAnnotation.get().value(), is("foo")); }
public Optional<META> findOn(Annotation annotation) { return repeatable ? findAllOn(annotation).reduce((a1, a2) -> { throw new IllegalArgumentException(annotation.annotationType() + " has multiple @" + metaAnnotationClass.getSimpleName() + " annotations. Please use " + MetaAnnotation.class.getSimpleName() + "#findAllOn(Annotation) for repeatable annotations."); }) : Optional.ofNullable(annotation.annotationType().getAnnotation(metaAnnotationClass)); }
MetaAnnotation { public Optional<META> findOn(Annotation annotation) { return repeatable ? findAllOn(annotation).reduce((a1, a2) -> { throw new IllegalArgumentException(annotation.annotationType() + " has multiple @" + metaAnnotationClass.getSimpleName() + " annotations. Please use " + MetaAnnotation.class.getSimpleName() + "#findAllOn(Annotation) for repeatable annotations."); }) : Optional.ofNullable(annotation.annotationType().getAnnotation(metaAnnotationClass)); } }
MetaAnnotation { public Optional<META> findOn(Annotation annotation) { return repeatable ? findAllOn(annotation).reduce((a1, a2) -> { throw new IllegalArgumentException(annotation.annotationType() + " has multiple @" + metaAnnotationClass.getSimpleName() + " annotations. Please use " + MetaAnnotation.class.getSimpleName() + "#findAllOn(Annotation) for repeatable annotations."); }) : Optional.ofNullable(annotation.annotationType().getAnnotation(metaAnnotationClass)); } private  MetaAnnotation(Class<META> metaAnnotationClass); }
MetaAnnotation { public Optional<META> findOn(Annotation annotation) { return repeatable ? findAllOn(annotation).reduce((a1, a2) -> { throw new IllegalArgumentException(annotation.annotationType() + " has multiple @" + metaAnnotationClass.getSimpleName() + " annotations. Please use " + MetaAnnotation.class.getSimpleName() + "#findAllOn(Annotation) for repeatable annotations."); }) : Optional.ofNullable(annotation.annotationType().getAnnotation(metaAnnotationClass)); } private  MetaAnnotation(Class<META> metaAnnotationClass); static MetaAnnotation<META> of(Class<META> metaAnnotationClass); boolean isRepeatable(); boolean isPresentOnAnyAnnotationOn(AnnotatedElement annotatedElement); boolean isPresentOn(@CheckForNull Annotation annotation); Optional<META> findOn(Annotation annotation); Stream<META> findAllOn(Annotation annotation); Stream<Annotation> findAnnotatedAnnotationsOn(AnnotatedElement annotatedElement); BinaryOperator<A> onlyOneOn(AnnotatedElement annotatedElement); Supplier<? extends IllegalArgumentException> missingAnnotation(Annotation annotation,
            AnnotatedElement annotatedElement,
            String checkerMethod); }
MetaAnnotation { public Optional<META> findOn(Annotation annotation) { return repeatable ? findAllOn(annotation).reduce((a1, a2) -> { throw new IllegalArgumentException(annotation.annotationType() + " has multiple @" + metaAnnotationClass.getSimpleName() + " annotations. Please use " + MetaAnnotation.class.getSimpleName() + "#findAllOn(Annotation) for repeatable annotations."); }) : Optional.ofNullable(annotation.annotationType().getAnnotation(metaAnnotationClass)); } private  MetaAnnotation(Class<META> metaAnnotationClass); static MetaAnnotation<META> of(Class<META> metaAnnotationClass); boolean isRepeatable(); boolean isPresentOnAnyAnnotationOn(AnnotatedElement annotatedElement); boolean isPresentOn(@CheckForNull Annotation annotation); Optional<META> findOn(Annotation annotation); Stream<META> findAllOn(Annotation annotation); Stream<Annotation> findAnnotatedAnnotationsOn(AnnotatedElement annotatedElement); BinaryOperator<A> onlyOneOn(AnnotatedElement annotatedElement); Supplier<? extends IllegalArgumentException> missingAnnotation(Annotation annotation,
            AnnotatedElement annotatedElement,
            String checkerMethod);  }