Class JDK15AnnotationFinder

  • All Implemented Interfaces:
    IAnnotationFinder

    public class JDK15AnnotationFinder
    extends java.lang.Object
    implements IAnnotationFinder
    This class implements IAnnotationFinder with JDK5 annotations
    • Field Detail

      • m_annotationMap

        private final java.util.Map<java.lang.Class<? extends IAnnotation>,​java.lang.Class<? extends java.lang.annotation.Annotation>> m_annotationMap
      • m_annotations

        private final java.util.Map<java.lang.String,​IAnnotation> m_annotations
    • Method Detail

      • findAnnotationInSuperClasses

        private <A extends java.lang.annotation.Annotation> A findAnnotationInSuperClasses​(java.lang.Class<?> cls,
                                                                                           java.lang.Class<A> a)
      • findAnnotation

        public <A extends IAnnotation> A findAnnotation​(java.lang.reflect.Method m,
                                                        java.lang.Class<A> annotationClass)
        Specified by:
        findAnnotation in interface IAnnotationFinder
        Type Parameters:
        A - The expected IAnnotation type
        Parameters:
        m - - The corresponding Method
        annotationClass - - The class on which annotation is to be looked for.
        Returns:
        The annotation on the method. If not found, return the annotation on the declaring class. If not found, return null.
      • findAnnotation

        public <A extends IAnnotation> A findAnnotation​(java.lang.Class<?> clazz,
                                                        java.lang.reflect.Method m,
                                                        java.lang.Class<A> annotationClass)
        Specified by:
        findAnnotation in interface IAnnotationFinder
      • transform

        private void transform​(IAnnotation a,
                               java.lang.Class<?> testClass,
                               java.lang.reflect.Constructor<?> testConstructor,
                               java.lang.reflect.Method testMethod,
                               java.lang.Class<?> whichClass)
      • findAnnotation

        public <A extends IAnnotation> A findAnnotation​(java.lang.Class<?> cls,
                                                        java.lang.Class<A> annotationClass)
        Specified by:
        findAnnotation in interface IAnnotationFinder
        Type Parameters:
        A - The expected IAnnotation type
        Parameters:
        cls - - The corresponding class.
        annotationClass - - The class on which annotation is to be looked for.
        Returns:
        The annotation on the class or null if none found.
      • findAnnotation

        public <A extends IAnnotation> A findAnnotation​(java.lang.reflect.Constructor<?> cons,
                                                        java.lang.Class<A> annotationClass)
        Specified by:
        findAnnotation in interface IAnnotationFinder
        Type Parameters:
        A - The expected IAnnotation type
        Parameters:
        cons - - The corresponding Constructor
        annotationClass - - The class on which annotation is to be looked for.
        Returns:
        The annotation on the method. If not found, return the annotation on the declaring class. If not found, return null.
      • findInheritedAnnotations

        public <A extends IAnnotation> java.util.List<A> findInheritedAnnotations​(java.lang.Class<?> cls,
                                                                                  java.lang.Class<A> annotationClass)
        Specified by:
        findInheritedAnnotations in interface IAnnotationFinder
        Type Parameters:
        A - - The expected IAnnotation type
        Parameters:
        cls - - The corresponding class.
        annotationClass - - The class on which annotation is to be looked for.
        Returns:
        The annotations on the inherited interfaces. If not found, return the annotations on the declaring interface. If not found, return an empty list.
      • findSuperInterface

        private <A extends IAnnotation> void findSuperInterface​(java.lang.Class<?> cls,
                                                                java.lang.Class<?> inter,
                                                                java.lang.Class<A> annotationClass,
                                                                java.lang.Class<? extends java.lang.annotation.Annotation> a,
                                                                java.util.List<A> annotations)
      • findAnnotation

        private <A extends IAnnotation> A findAnnotation​(java.lang.Class<?> cls,
                                                         java.lang.annotation.Annotation a,
                                                         java.lang.Class<A> annotationClass,
                                                         java.lang.Class<?> testClass,
                                                         java.lang.reflect.Constructor<?> testConstructor,
                                                         java.lang.reflect.Method testMethod,
                                                         Pair<java.lang.annotation.Annotation,​?> p,
                                                         java.lang.Class<?> whichClass)
      • hasTestInstance

        public boolean hasTestInstance​(java.lang.reflect.Method method,
                                       int i)
        Specified by:
        hasTestInstance in interface IAnnotationFinder
        Parameters:
        method - The Method
        i - The parameter index
        Returns:
        true if the ith parameter of the given method has the annotation @TestInstance.
      • findOptionalValues

        public java.lang.String[] findOptionalValues​(java.lang.reflect.Method method)
        Specified by:
        findOptionalValues in interface IAnnotationFinder
        Parameters:
        method - The Method
        Returns:
        the @Optional values of this method's parameters (null if the parameter isn't optional)
      • findOptionalValues

        public java.lang.String[] findOptionalValues​(java.lang.reflect.Constructor<?> method)
        Specified by:
        findOptionalValues in interface IAnnotationFinder
        Parameters:
        method - The Constructor
        Returns:
        the @Optional values of this method's parameters (null if the parameter isn't optional)
      • optionalValues

        private java.lang.String[] optionalValues​(java.lang.annotation.Annotation[][] annotations)