public class VaniReflectionUtil extends Object
| Constructor and Description |
|---|
VaniReflectionUtil() |
| Modifier and Type | Method and Description |
|---|---|
Annotation |
getAnnotatedAnnotation(Field field,
Class<? extends Annotation> annotationClass)
method to find first annotation of given field, which is annotated with
specified annotation.
|
List<Method> |
getAnnotatedMethodsWith(Class<?> targetClass,
Class<?> annotation,
Class<?> returnType)
this method returns a list with all methods for given class with
specified annotation and return type.
|
Method |
getAnnotatedMethodWith(Class<?> targetClass,
Class<?> annotation,
Class<?> returnType)
this method returns the first method of given class with specified
annotation and return type.
|
Class<?> |
getElementTargetType(Field field)
method to get the target type of given field.
|
Field |
getField(String name,
Class<?> clazz)
methods to get field with specified name of given class.
|
FieldTypeInfo |
getFieldTypeInfo(Field field,
Object bean)
This method will generate a
FieldTypeInfo object with provided
information. |
Class<?> |
getFirstParameterizedType(Field field)
method to get the first type of given parameterized field.
|
<T extends Annotation> |
getTypeAnnotation(Class<T> annotationClazz,
Class<?> clazz)
this method returns target annotation instance of given class or one of
its super classes.
|
boolean |
hasMethodWithAnnotation(Class<?> targetClass,
Class<? extends Annotation> annotationClass) |
<T> void |
setFieldValue(String name,
Object bean,
T value) |
public Class<?> getFirstParameterizedType(Field field)
NULL will be returned.field - NULL if
not available.public Class<?> getElementTargetType(Field field)
field - List,
else type of field will be returned. If list has no generic type,
result will be NULL.public FieldTypeInfo getFieldTypeInfo(Field field, Object bean)
FieldTypeInfo object with provided
information.field - bean - public Field getField(String name, Class<?> clazz) throws Exception
name - clazz - NULL if no field with specified
name could be found in given class or any super class.Exceptionpublic Method getAnnotatedMethodWith(Class<?> targetClass, Class<?> annotation, Class<?> returnType)
targetClass - annotation - returnType - returnType of method (NULL will ignore this criteria),
comparing will use equals-methodpublic List<Method> getAnnotatedMethodsWith(Class<?> targetClass, Class<?> annotation, Class<?> returnType)
targetClass - annotation - returnType - returnType of method (NULL will ignore this criteria),
comparing will use equals-methodpublic <T extends Annotation> T getTypeAnnotation(Class<T> annotationClazz, Class<?> clazz)
annotationClazz - target annotation classclazz - target classNULL if not
exists in target class or one of its super classespublic <T> void setFieldValue(String name, Object bean, T value) throws IllegalVaniFieldException, IllegalAccessException
public Annotation getAnnotatedAnnotation(Field field, Class<? extends Annotation> annotationClass)
field - annotationClass - public boolean hasMethodWithAnnotation(Class<?> targetClass, Class<? extends Annotation> annotationClass)
Copyright © 2016. All rights reserved.