Class ReflectionHelper
java.lang.Object
org.jboss.arquillian.graphene.enricher.ReflectionHelper
SecurityActions
A set of privileged actions that are not to leak out of this package
- Version:
- $Revision: $
- Author:
- ALR
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends Annotation>
TfindAnnotation(Annotation[] annotations, Class<T> needle) Finds some annotation in the given array of annotationsstatic <T> Constructor<T>getAssignableConstructor(Class<T> clazz, Class<?>... argumentTypes) static Constructor<?>getConstructor(Class<?> clazz, Class<?>... argumentTypes) Obtains the Constructor specified from the given Class and argument typesgetFieldsWithAnnotatedAnnotation(Class<?> source, Class<? extends Annotation> annotationClass) getFieldsWithAnnotation(Class<?> source, Class<? extends Annotation> annotationClass) getMethodsWithAnnotation(Class<?> source, Class<? extends Annotation> annotationClass) getParametersWithAnnotation(Method method, Class<? extends Annotation> annotationClass) Returns all couples of found parameter annotated with the given annotation and an array of all annotations the parameter is annotated with for the given methodstatic Class<?>getQualifier(Annotation[] annotations) static ClassLoaderObtains the Thread Context ClassLoaderstatic booleanhasConstructor(Class<?> clazz, Class<?>... argumentTypes) static booleanisClassPresent(String name) static <T> TnewInstance(String className, Class<?>[] argumentTypes, Object[] arguments, Class<T> expectedType) Create a new instance by finding a constructor that matches the argumentTypes signature using the arguments for instantiation.
-
Method Details
-
getThreadContextClassLoader
Obtains the Thread Context ClassLoader -
getConstructor
public static Constructor<?> getConstructor(Class<?> clazz, Class<?>... argumentTypes) throws NoSuchMethodException Obtains the Constructor specified from the given Class and argument types- Parameters:
clazz-argumentTypes-- Returns:
- Throws:
NoSuchMethodException
-
getAssignableConstructor
public static <T> Constructor<T> getAssignableConstructor(Class<T> clazz, Class<?>... argumentTypes) throws NoSuchMethodException - Throws:
NoSuchMethodException
-
hasConstructor
-
newInstance
public static <T> T newInstance(String className, Class<?>[] argumentTypes, Object[] arguments, Class<T> expectedType) Create a new instance by finding a constructor that matches the argumentTypes signature using the arguments for instantiation.- Parameters:
className- Full classname of class to createargumentTypes- The constructor argument typesarguments- The constructor arguments- Returns:
- a new instance
- Throws:
IllegalArgumentException- if className, argumentTypes, or arguments are nullRuntimeException- if any exceptions during creation
-
isClassPresent
-
getFields
-
getFieldsWithAnnotation
public static List<Field> getFieldsWithAnnotation(Class<?> source, Class<? extends Annotation> annotationClass) -
getFieldsWithAnnotatedAnnotation
public static List<Field> getFieldsWithAnnotatedAnnotation(Class<?> source, Class<? extends Annotation> annotationClass) -
getMethodsWithAnnotation
public static List<Method> getMethodsWithAnnotation(Class<?> source, Class<? extends Annotation> annotationClass) -
getParametersWithAnnotation
public static List<Object[]> getParametersWithAnnotation(Method method, Class<? extends Annotation> annotationClass) Returns all couples of found parameter annotated with the given annotation and an array of all annotations the parameter is annotated with for the given method- Parameters:
method- - the method where the parameters should be examinedannotationClass- - the annotation the parameters should be annotated with- Returns:
- list of couples in an object array that consist of found parameter annotated with the given annotation and an array of all annotations the parameter is annotated with
-
findAnnotation
Finds some annotation in the given array of annotations- Parameters:
annotations- - array of annotationsneedle- - annotation we are looking for- Returns:
- the found annotation
-
getQualifier
-