|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.wicketstuff.rest.utils.reflection.ReflectionUtils
public class ReflectionUtils
Utility methods to work with reflection entities
Constructor Summary | |
---|---|
ReflectionUtils()
|
Method Summary | ||
---|---|---|
static
|
findAnnotation(Annotation[] parameterAnnotations,
Class<T> targetAnnotation)
Utility method to find if an annotation type is present in an array of annotations. |
|
static Method |
findMethod(Class<?> clazz,
String name,
Class<?>... parameterTypes)
Safely search for a method with a given signature (name + parameter types) on a given class. |
|
static
|
findMethodParameterAnnotation(Method ownerMethod,
int paramIndex,
Class<T> targetAnnotation)
Return the specified annotation for the method parameter at a given position (see paramIndex ). |
|
static
|
getAnnotationField(Annotation annotation,
String fieldName,
T defaultValue)
Get the value of an annotation field. |
|
static Annotation |
getAnnotationParam(int i,
Method method)
Check if a parameter is annotated with an AnnotatedParam annotation. |
|
static List<Class<?>> |
getElementsClasses(Collection<?> collection)
Extract the list of types of every element of a given collection. |
|
static
|
invokeMethod(Object target,
String name,
Class<?>... parameterTypes)
Safely invoke a method with the given signature (name + parameter types) on the given target object. |
|
static boolean |
isParameterAnnotatedWith(int i,
Method method,
Class<? extends Annotation> targetAnnotation)
Check if a parameter is annotated with a given annotation. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ReflectionUtils()
Method Detail |
---|
public static boolean isParameterAnnotatedWith(int i, Method method, Class<? extends Annotation> targetAnnotation)
i
- method parameter index.method
- the method the parameter belongs to.targetAnnotation
- the annotation type we want to check for.
public static Annotation getAnnotationParam(int i, Method method)
AnnotatedParam
annotation.
i
- method parameter index.method
- the method the parameter belongs to.
AnnotatedParam
public static <T extends Annotation> T findAnnotation(Annotation[] parameterAnnotations, Class<T> targetAnnotation)
parameterAnnotations
- the array of annotations we will look in.targetAnnotation
- the type of annotation we are looking for.
public static <T extends Annotation> T findMethodParameterAnnotation(Method ownerMethod, int paramIndex, Class<T> targetAnnotation)
paramIndex
).
ownerMethod
- the parameter's methodparamIndex
- the parameter indextargetAnnotation
- the annotation type to search for
public static Method findMethod(Class<?> clazz, String name, Class<?>... parameterTypes)
clazz
- the target classname
- method nameparameterTypes
- method's parameters types.
public static <T> T invokeMethod(Object target, String name, Class<?>... parameterTypes)
target
- the target objectname
- method nameparameterTypes
- method's parameters types.
public static <T> T getAnnotationField(Annotation annotation, String fieldName, T defaultValue)
annotation
- the target annotationfieldName
- the field namedefaultValue
- the default value to return
public static List<Class<?>> getElementsClasses(Collection<?> collection)
collection
- the collection in input.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |