|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.nuiton.util.ReflectUtil
public class ReflectUtil
Des méthodes utiles d'introspection
| Constructor Summary | |
|---|---|
ReflectUtil()
|
|
| Method Summary | ||
|---|---|---|
static Class<?> |
boxType(Class<?> type)
Obtain the boxed type of any incoming type. |
|
static Set<Field> |
getAllDeclaredFields(Class<?> objectClass)
Obtain all the declared fields of the given objectClass with a
deep scan inside super classes and interfaces. |
|
protected static void |
getAllDeclaredFields(Class<?> objectClass,
Set<Class<?>> visitedClasses,
Set<Field> result)
|
|
static Set<Method> |
getAllDeclaredMethods(Class<?> objectClass)
Obtain all the declared methods of the given objectClass with a
deep scan inside super classes and interfaces. |
|
protected static void |
getAllDeclaredMethods(Class<?> objectClass,
Set<Class<?>> visitedClasses,
Set<Method> result)
|
|
static
|
getConstant(Class<?> klass,
String fieldName)
|
|
static
|
getConstants(Class<?> klass,
Class<T> searchingClass)
Recherche dans une classe donnée klazz, les constantes d'un
certain type searchingClass et les retourne. |
|
static Method |
getDeclaredMethod(Class<?> klass,
String methodName,
boolean strict,
Object... arguments)
Cherche une methode selon son nom et ses paramètres d'invocation. |
|
protected static Method |
getDeclaredMethod(Class<?> klass,
String methodName,
Set<Class<?>> visitedClasses,
Object... arguments)
|
|
static
|
getEnumClass(Class<?> type)
Convertit une classe non typée, en une classe d'enum |
|
static
|
getFieldAnnotation(Class<?> objectClass,
Class<A> annotationClass)
Obtain all the fields with the given annotation type. |
|
static
|
getFieldAnnotation(Class<?> objectClass,
Class<A> annotationClass,
boolean deepVisit)
Obtain all the fields with the given annotation type. |
|
protected static
|
getFieldAnnotation(Class<?> objectClass,
Class<A> annotationClass,
boolean deepVisit,
Set<Class<?>> visitedClasses,
Map<Field,A> result)
|
|
static
|
getMethodAnnotation(Class<?> objectClass,
Class<A> annotationClass)
Obtain all the methods with the given annotation type. |
|
static
|
getMethodAnnotation(Class<?> objectClass,
Class<A> annotationClass,
boolean deepVisit)
Obtain all the methods with the given annotation type. |
|
protected static
|
getMethodAnnotation(Class<?> objectClass,
Class<A> annotationClass,
boolean deepVisit,
Set<Class<?>> visitedClasses,
Map<Method,A> result)
|
|
static boolean |
isConstantField(Field field)
Pour déterminer si un champ d'une classe est une constante (modifiers sont static, final et public) |
|
static Class<?> |
unboxType(Class<?> type)
Obtain the unboxed type of any incoming type. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ReflectUtil()
| Method Detail |
|---|
public static boolean isConstantField(Field field)
field - le champs à tester
true si les modifiers sont final, static et public
public static <T> List<T> getConstants(Class<?> klass,
Class<T> searchingClass)
klazz, les constantes d'un
certain type searchingClass et les retourne.
L'algorithme parcourt aussi les superclasses.
T - enumeration's typeklass - la classe contenant les constantessearchingClass - le type des champs constants à récupérer
RuntimeException - si problème lors de la récupération
public static <T> T getConstant(Class<?> klass,
String fieldName)
T - enumeration's typeklass - the required classfieldName - the required constant name
public static <T extends Enum<T>> Class<T> getEnumClass(Class<?> type)
throws IllegalArgumentException
T - enumeration's typetype - la classe a typer
IllegalArgumentException - si le type est null ou non une extension
de la classe Enum.
public static Method getDeclaredMethod(Class<?> klass,
String methodName,
boolean strict,
Object... arguments)
throws IllegalArgumentException
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
IllegalArgumentException - si la méthode n'est pas trouvée et que
le drapeau strict est à truepublic static Class<?> boxType(Class<?> type)
type - the type to box
Class.isPrimitive()public static Class<?> unboxType(Class<?> type)
type - the type to unbox
Class.isPrimitive()public static Set<Field> getAllDeclaredFields(Class<?> objectClass)
objectClass with a
deep scan inside super classes and interfaces.
Note: The type Object will not be scanned.
objectClass - the object class to scan
public static Set<Method> getAllDeclaredMethods(Class<?> objectClass)
objectClass with a
deep scan inside super classes and interfaces.
Note: The type Object will not be scanned.
objectClass - the object class to scan
public static <A extends Annotation> Map<Field,A> getFieldAnnotation(Class<?> objectClass,
Class<A> annotationClass)
A - type of annotation to scanobjectClass - the type to scanannotationClass - the type of annotation to scan
public static <A extends Annotation> Map<Field,A> getFieldAnnotation(Class<?> objectClass,
Class<A> annotationClass,
boolean deepVisit)
deepVisit is setted to true.
Note: The type Object will not be scanned.
A - type of annotation to scanobjectClass - the type to scanannotationClass - the type of annotation to scandeepVisit - flag to visit deeply the class (if set to
true, will also scan super classes
and interfaces)
public static <A extends Annotation> Map<Method,A> getMethodAnnotation(Class<?> objectClass,
Class<A> annotationClass)
A - type of annotation to scanobjectClass - the type to scanannotationClass - the type of annotation to scan
public static <A extends Annotation> Map<Method,A> getMethodAnnotation(Class<?> objectClass,
Class<A> annotationClass,
boolean deepVisit)
deepVisit is setted to true.
Note: The type Object will not be scanned.
A - type of annotation to scanobjectClass - the type to scanannotationClass - the type of annotation to scandeepVisit - flag to visit deeply the class (if set to
true, will also scan super classes
and interfaces)
protected static Method getDeclaredMethod(Class<?> klass,
String methodName,
Set<Class<?>> visitedClasses,
Object... arguments)
protected static void getAllDeclaredFields(Class<?> objectClass,
Set<Class<?>> visitedClasses,
Set<Field> result)
protected static void getAllDeclaredMethods(Class<?> objectClass,
Set<Class<?>> visitedClasses,
Set<Method> result)
protected static <A extends Annotation> void getFieldAnnotation(Class<?> objectClass,
Class<A> annotationClass,
boolean deepVisit,
Set<Class<?>> visitedClasses,
Map<Field,A> result)
protected static <A extends Annotation> void getMethodAnnotation(Class<?> objectClass,
Class<A> annotationClass,
boolean deepVisit,
Set<Class<?>> visitedClasses,
Map<Method,A> result)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||