Interface ReflectionService
-
- All Known Implementing Classes:
ReflectionsReflectionService,ServletContextReflectionService
public interface ReflectionServiceA service that provides reflection (introspection) support.- Author:
- Carl Harris
-
-
Method Summary
All Methods Instance Methods Abstract 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
<T> Set<Class<? extends T>> getSubTypesOf(Class<T> type)
Gets the set of classes that are subtypes of a given type.- Parameters:
type- the base type- Returns:
- set of types that implement/extend
type
-
getTypesAnnotatedWith
Set<Class<?>> getTypesAnnotatedWith(Class<? extends Annotation> annotation)
Gets the set of classes that have a given (type-level) annotation.- Parameters:
annotation- the subject annotation- Returns:
- set of classes
-
getAnnotation
<A extends Annotation> A getAnnotation(Class<?> subjectType, Class<A> annotationType)
Gets an annotation on a type.- 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
<A extends Annotation> A getAnnotation(Method subjectMethod, Class<A> annotationType)
Gets an annotation on a method.- 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
boolean isAbstractType(Class<?> type)
Tests whether the given type is an interface or abstract class.- Parameters:
type- the subject type- Returns:
trueiftypeis an interface or an abstract class
-
getMethods
Method[] getMethods(Class<?> type)
Gets the public methods of the given type.- Parameters:
type- the subject type- Returns:
- array containing the public methods of
type
-
-