public class ClassUtils
extends java.lang.Object
Constructor and Description |
---|
ClassUtils() |
Modifier and Type | Method and Description |
---|---|
static java.lang.Class<?> |
classForPrimitive(java.lang.Class<?> primClass) |
static <T> Pair<java.lang.Boolean,T> |
coerce(java.lang.Object o,
java.lang.Class<T> cls)
Try to convert an object into one of the specified class.
|
static <TT> TT |
evaluate(java.lang.Object object,
java.lang.Class<TT> cls)
Evaluate/dig or wrap the object of the given type cls from the object o,
which may be a Parameter or an Expression.
|
static java.util.List<java.lang.Class<?>> |
getAllClasses(java.lang.Object o) |
static java.lang.reflect.Field |
getField(java.lang.Object o,
java.lang.String fieldName)
Get the Field of the Class of the object with the given fieldName using
reflection.
|
static java.lang.reflect.Method[] |
getMethodsForName(java.lang.Class<?> cls,
java.lang.String methodName) |
static java.util.Map<java.lang.Class<?>,java.lang.Class<?>> |
getPrimToNonPrim() |
static boolean |
isNumber(java.lang.Class<?> type) |
static boolean |
isStatic(java.lang.reflect.Member method) |
static Pair<java.lang.Boolean,java.lang.Object> |
runMethod(boolean suppressErrors,
java.lang.Object o,
java.lang.reflect.Method method,
java.lang.Object... args) |
static Pair<java.lang.Boolean,java.lang.Object> |
runMethod(java.lang.Object o,
java.lang.reflect.Method m,
java.lang.Object... args)
Invoke the method from the given object with the given arguments.
|
public static java.lang.Class<?> classForPrimitive(java.lang.Class<?> primClass)
public static java.util.Map<java.lang.Class<?>,java.lang.Class<?>> getPrimToNonPrim()
public static Pair<java.lang.Boolean,java.lang.Object> runMethod(boolean suppressErrors, java.lang.Object o, java.lang.reflect.Method method, java.lang.Object... args)
public static boolean isStatic(java.lang.reflect.Member method)
public static Pair<java.lang.Boolean,java.lang.Object> runMethod(java.lang.Object o, java.lang.reflect.Method m, java.lang.Object... args) throws java.lang.IllegalArgumentException, java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException
o
- m
- args
- java.lang.IllegalArgumentException
java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
public static java.lang.reflect.Field getField(java.lang.Object o, java.lang.String fieldName) throws java.lang.IllegalArgumentException
o
- the object whose field is soughtfieldName
- java.lang.IllegalArgumentException
public static boolean isNumber(java.lang.Class<?> type)
type
- public static java.lang.reflect.Method[] getMethodsForName(java.lang.Class<?> cls, java.lang.String methodName)
cls
- methodName
- cls
(or inherited by cls
)
that have the simple name, methodName
.public static <T> Pair<java.lang.Boolean,T> coerce(java.lang.Object o, java.lang.Class<T> cls)
o
- the object to convert into type clscls
- the Class
of the object to returnpublic static <TT> TT evaluate(java.lang.Object object, java.lang.Class<TT> cls) throws java.lang.ClassCastException
object
- the object to evaluatecls
- the type of the object to findjava.lang.ClassCastException
public static java.util.List<java.lang.Class<?>> getAllClasses(java.lang.Object o)
o
-