|
||||||||||
| 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
|
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 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()
protected static Method getDeclaredMethod(Class<?> klass,
String methodName,
Set<Class<?>> visitedClasses,
Object... arguments)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||