Class ReflectionsReflectionService

    • Constructor Detail

      • ReflectionsReflectionService

        public ReflectionsReflectionService​(org.reflections.Reflections reflections)
        Constructs a new instance.
        Parameters:
        reflections -
    • Method Detail

      • getSubTypesOf

        public <T> Set<Class<? extends T>> getSubTypesOf​(Class<T> type)
        Gets the set of classes that are subtypes of a given type.
        Specified by:
        getSubTypesOf in interface ReflectionService
        Parameters:
        type - the base type
        Returns:
        set of types that implement/extend type
      • getTypesAnnotatedWith

        public Set<Class<?>> getTypesAnnotatedWith​(Class<? extends Annotation> annotation)
        Gets the set of classes that have a given (type-level) annotation.
        Specified by:
        getTypesAnnotatedWith in interface ReflectionService
        Parameters:
        annotation - the subject annotation
        Returns:
        set of classes
      • getAnnotation

        public <A extends Annotation> A getAnnotation​(Class<?> subjectType,
                                                      Class<A> annotationType)
        Gets an annotation on a type.
        Specified by:
        getAnnotation in interface ReflectionService
        Type Parameters:
        A - annotation type
        Parameters:
        subjectType - the subject type
        annotationType - class representating the annotation type
        Returns:
        annotation instance or null if there is no annotation of type A on subjectType
      • getAnnotation

        public <A extends Annotation> A getAnnotation​(Method subjectMethod,
                                                      Class<A> annotationType)
        Gets an annotation on a method.
        Specified by:
        getAnnotation in interface ReflectionService
        Type Parameters:
        A - annotation type
        Parameters:
        subjectMethod - the subject method
        annotationType - class representating the annotation type
        Returns:
        annotation instance or null if there is no annotation of type A on subjectType
      • isAbstractType

        public boolean isAbstractType​(Class<?> type)
        Tests whether the given type is an interface or abstract class.
        Specified by:
        isAbstractType in interface ReflectionService
        Parameters:
        type - the subject type
        Returns:
        true if type is an interface or an abstract class
      • getMethods

        public Method[] getMethods​(Class<?> type)
        Gets the public methods of the given type.
        Specified by:
        getMethods in interface ReflectionService
        Parameters:
        type - the subject type
        Returns:
        array containing the public methods of type
      • getReturnType

        public Class<?> getReturnType​(Method method)
        Gets the return type of the given method.
        Specified by:
        getReturnType in interface ReflectionService
        Parameters:
        method - the subject method
        Returns:
        return type