Package org.nuiton.jaxx.runtime.util
Class ReflectUtil
- java.lang.Object
-
- org.nuiton.jaxx.runtime.util.ReflectUtil
-
public class ReflectUtil extends Object
Created by tchemit on 12/07/17.- Author:
- Tony Chemit - dev@tchemit.fr
-
-
Constructor Summary
Constructors Constructor Description ReflectUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Class<?>boxType(Class<?> type)Obtain the boxed type of any incoming type.static MethodgetDeclaredMethod(Class<?> klass, String methodName, boolean strict, Object... arguments)Cherche une methode selon son nom et ses paramètres d'invocation.protected static MethodgetDeclaredMethod(Class<?> klass, String methodName, Set<Class<?>> visitedClasses, Object... arguments)static <A extends Annotation>
Map<Field,A>getFieldAnnotation(Class<?> objectClass, Class<A> annotationClass, boolean deepVisit)Obtain all the fields with the given annotation type.protected static <A extends Annotation>
voidgetFieldAnnotation(Class<?> objectClass, Class<A> annotationClass, boolean deepVisit, Set<Class<?>> visitedClasses, Map<Field,A> result)static <A extends Annotation>
Map<Method,A>getMethodAnnotation(Class<?> objectClass, Class<A> annotationClass, boolean deepVisit)Obtain all the methods with the given annotation type.protected static <A extends Annotation>
voidgetMethodAnnotation(Class<?> objectClass, Class<A> annotationClass, boolean deepVisit, Set<Class<?>> visitedClasses, Map<Method,A> result)
-
-
-
Method Detail
-
getDeclaredMethod
public static Method getDeclaredMethod(Class<?> klass, String methodName, boolean strict, Object... arguments) throws IllegalArgumentException
Cherche une methode selon son nom et ses paramètres d'invocation.- Parameters:
klass- la classe dans laquelle rechercher la méthodemethodName- le nom de la méthode recherchéestrict- un drapeau pour déclancher une exception si la méthode n'est pas trouvéearguments- les arguments d'invocation de la méthode- Returns:
- la méthode trouvée
- Throws:
IllegalArgumentException- si la méthode n'est pas trouvée et que le drapeaustrictest àtrue- Since:
- 1.3.1
-
getDeclaredMethod
protected static Method getDeclaredMethod(Class<?> klass, String methodName, Set<Class<?>> visitedClasses, Object... arguments)
-
boxType
public static Class<?> boxType(Class<?> type)
Obtain the boxed type of any incoming type.If incoming type is not a primitive type, then just returns himself.
- Parameters:
type- the type to box- Returns:
- the boxed type
- Since:
- 1.3.1
- See Also:
Class.isPrimitive()
-
getFieldAnnotation
public static <A extends Annotation> Map<Field,A> getFieldAnnotation(Class<?> objectClass, Class<A> annotationClass, boolean deepVisit)
Obtain all the fields with the given annotation type.Note: This method will scan deeply the given type if parameter
deepVisitis setted totrue.Note: The type
Objectwill not be scanned.- Type Parameters:
A- type of annotation to scan- Parameters:
objectClass- the type to scanannotationClass- the type of annotation to scandeepVisit- flag to visit deeply the class (if set totrue, will also scan super classes and interfaces)- Returns:
- the dictionnary of fields with the given annotation
- Since:
- 2.0
-
getMethodAnnotation
public static <A extends Annotation> Map<Method,A> getMethodAnnotation(Class<?> objectClass, Class<A> annotationClass, boolean deepVisit)
Obtain all the methods with the given annotation type. Note: This method will scan deeply the given type if parameterdeepVisitis setted totrue. Note: The typeObjectwill not be scanned.- Type Parameters:
A- type of annotation to scan- Parameters:
objectClass- the type to scanannotationClass- the type of annotation to scandeepVisit- flag to visit deeply the class (if set totrue, will also scan super classes and interfaces)- Returns:
- the dictionnary of methods with the given annotation
- Since:
- 2.0
-
getFieldAnnotation
protected static <A extends Annotation> void getFieldAnnotation(Class<?> objectClass, Class<A> annotationClass, boolean deepVisit, Set<Class<?>> visitedClasses, Map<Field,A> result)
-
-