Class ReflectionsReflectionService
- java.lang.Object
-
- org.soulwing.prospecto.jaxrs.runtime.discovery.ReflectionsReflectionService
-
- All Implemented Interfaces:
ReflectionService
- Direct Known Subclasses:
ServletContextReflectionService
public class ReflectionsReflectionService extends Object implements ReflectionService
AReflectionServicethat delegates to theReflectionsutility and the Java Reflection API.- Author:
- Carl Harris
-
-
Constructor Summary
Constructors Constructor Description ReflectionsReflectionService(org.reflections.Reflections reflections)Constructs a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <A extends Annotation>
AgetAnnotation(Class<?> subjectType, Class<A> annotationType)Gets an annotation on a type.<A extends Annotation>
AgetAnnotation(Method subjectMethod, Class<A> annotationType)Gets an annotation on a method.Method[]getMethods(Class<?> type)Gets the public methods of the given type.Class<?>getReturnType(Method method)Gets the return type of the given method.<T> Set<Class<? extends T>>getSubTypesOf(Class<T> type)Gets the set of classes that are subtypes of a given type.Set<Class<?>>getTypesAnnotatedWith(Class<? extends Annotation> annotation)Gets the set of classes that have a given (type-level) annotation.booleanisAbstractType(Class<?> type)Tests whether the given type is an interface or abstract class.
-
-
-
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:
getSubTypesOfin interfaceReflectionService- 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:
getTypesAnnotatedWithin interfaceReflectionService- 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:
getAnnotationin interfaceReflectionService- Type Parameters:
A- annotation type- Parameters:
subjectType- the subject typeannotationType- class representating the annotation type- Returns:
- annotation instance or
nullif there is no annotation of typeAonsubjectType
-
getAnnotation
public <A extends Annotation> A getAnnotation(Method subjectMethod, Class<A> annotationType)
Gets an annotation on a method.- Specified by:
getAnnotationin interfaceReflectionService- Type Parameters:
A- annotation type- Parameters:
subjectMethod- the subject methodannotationType- class representating the annotation type- Returns:
- annotation instance or
nullif there is no annotation of typeAonsubjectType
-
isAbstractType
public boolean isAbstractType(Class<?> type)
Tests whether the given type is an interface or abstract class.- Specified by:
isAbstractTypein interfaceReflectionService- Parameters:
type- the subject type- Returns:
trueiftypeis an interface or an abstract class
-
getMethods
public Method[] getMethods(Class<?> type)
Gets the public methods of the given type.- Specified by:
getMethodsin interfaceReflectionService- 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:
getReturnTypein interfaceReflectionService- Parameters:
method- the subject method- Returns:
- return type
-
-