Class OverriddenMethodAnnotationSupport


  • public final class OverriddenMethodAnnotationSupport
    extends java.lang.Object
    Adapted from https://stackoverflow.com/a/49164791/32352
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <A extends java.lang.annotation.Annotation>
      java.util.Optional<A>
      findDeclaredOrInheritedAnnotation​(java.lang.reflect.Method m, java.lang.Class<A> t)
      Returns the optional first element of the list returned by getAnnotations, or null if the list would be empty.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • OverriddenMethodAnnotationSupport

        public OverriddenMethodAnnotationSupport()
    • Method Detail

      • findDeclaredOrInheritedAnnotation

        public static <A extends java.lang.annotation.Annotation> java.util.Optional<A> findDeclaredOrInheritedAnnotation​(java.lang.reflect.Method m,
                                                                                                                          java.lang.Class<A> t)
        Returns the optional first element of the list returned by getAnnotations, or null if the list would be empty.
        Type Parameters:
        A - the type of the annotation to find.
        Parameters:
        m - the method to begin the search from.
        t - the type of the annotation to find.
        Returns:
        optional of first annotation found of the specified type which is present on m, or present on any methods which m overrides.
        Throws:
        java.lang.NullPointerException - if any argument is null.