public class Reflection
extends java.lang.Object
Constructor and Description |
---|
Reflection() |
Modifier and Type | Method and Description |
---|---|
static java.util.List<java.lang.Class<?>> |
getAllInterfaces(java.lang.Class<?> cls)
Get all implemented interfaces and classes.
|
static java.lang.Class<?> |
getBoxed(java.lang.Class<?> cls)
Return the boxed class 'cls' if the 'clas' class is a primary type.
|
static <T> java.lang.reflect.Constructor<T> |
getConstructor(java.lang.Class<T> cls,
java.util.List<java.lang.Class<?>> argsCls)
Get a constructor.
|
static java.lang.Throwable |
getThrowableCause(java.lang.Throwable e)
Get the original cause of an exception.
|
static ConfigurationException |
getThrowableConfigurationException(java.lang.Throwable e)
Get the original ConfigurationException of an exception.
|
static java.lang.String |
getThrowableMessage(java.lang.Throwable e)
Get the original message of an exception.
|
static boolean |
hasSetters(java.lang.Class<?> cls)
Return true if the class 'cls' has setters (void setXXX())
|
static boolean |
hasValueOf(java.lang.Class<?> cls)
Return true if the class 'cls' has either:
"public
|
static boolean |
hasValueOf(java.lang.Class<?> cls,
java.lang.Class<?> paramClass)
Return true if the class 'cls' has either:
"public static
|
static java.lang.Object |
invoke(java.lang.Class<?> cls,
java.lang.String methodName,
java.lang.Object obj,
java.lang.Object... args)
Invoke a method, with verbose exception handling.
|
static java.lang.Object |
invoke(java.lang.reflect.Method method,
java.lang.Object obj,
java.lang.Object... args)
Invoke a method, with verbose exception handling.
|
static boolean |
isGenericTypeClass(java.lang.Class<?> cls)
Returns true if the class 'cls' is a generic type ; that is, either the
Object class, or an interface.
|
static boolean |
isSetter(java.lang.reflect.Method method)
Return true if the method 'method' is a setter (void setXXX())
|
static boolean |
isVisibleSetter(java.lang.reflect.Method method)
Return true if the method 'method' is a setter (void setXXX())
|
static <T> T |
newInstance(java.lang.reflect.Constructor<T> cons,
java.util.List<java.lang.Object> args)
Constructor.newInstance()
|
static <T> java.lang.Object |
toValueOf(java.lang.Class<T> cls,
java.lang.Class<?> paramClass,
java.lang.Object value)
Transform the value "value" of type "paramClass" into an object of class
"cls", using the static valueOf() method, or the standard constructor.
|
static <T> java.lang.Object |
toValueOf(java.lang.Class<T> cls,
java.lang.String value)
Transform the string value "value" into an object of class "cls", using
the standard constructor, or the static valueOf() method.
|
static <T> java.lang.Object |
toValuesOf(java.lang.Class<T> cls,
java.lang.Class<?> paramClass,
java.lang.Object[] values)
Transform an array of values "values" of type "paramClass" into an array
of objects of class "cls", using the static valueOf() method, or the
standard constructor.
|
static <T> java.lang.Object |
toValuesOf(java.lang.Class<T> cls,
java.lang.String[] values)
Transform an array of strings "values" into an array of objects of class
"cls", using the standard constructor, or the static valueOf() method.
|
public static <T> java.lang.reflect.Constructor<T> getConstructor(java.lang.Class<T> cls, java.util.List<java.lang.Class<?>> argsCls) throws java.lang.NoSuchMethodException
cls
- the class nameargsCls
- argument typesjava.lang.NoSuchMethodException
public static <T> T newInstance(java.lang.reflect.Constructor<T> cons, java.util.List<java.lang.Object> args) throws java.lang.InstantiationException, java.lang.IllegalAccessException, java.lang.IllegalArgumentException, java.lang.reflect.InvocationTargetException
java.lang.InstantiationException
java.lang.IllegalAccessException
java.lang.IllegalArgumentException
java.lang.reflect.InvocationTargetException
public static java.lang.Object invoke(java.lang.reflect.Method method, java.lang.Object obj, java.lang.Object... args) throws java.lang.Exception
java.lang.Exception
public static java.lang.Object invoke(java.lang.Class<?> cls, java.lang.String methodName, java.lang.Object obj, java.lang.Object... args) throws java.lang.Exception
java.lang.Exception
public static java.lang.Class<?> getBoxed(java.lang.Class<?> cls)
public static boolean isSetter(java.lang.reflect.Method method)
method
- the method to inspectpublic static boolean isGenericTypeClass(java.lang.Class<?> cls)
cls
- public static boolean isVisibleSetter(java.lang.reflect.Method method)
method
- the method to inspectpublic static boolean hasSetters(java.lang.Class<?> cls)
cls
- the class to inspectpublic static boolean hasValueOf(java.lang.Class<?> cls, java.lang.Class<?> paramClass)
cls
- the class to inspectparamClass
- the parameter typepublic static boolean hasValueOf(java.lang.Class<?> cls)
cls
- the class to inspectpublic static <T> java.lang.Object toValueOf(java.lang.Class<T> cls, java.lang.Class<?> paramClass, java.lang.Object value) throws java.lang.NoSuchMethodException, java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException, java.lang.Exception
java.lang.NoSuchMethodException
java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
java.lang.Exception
public static <T> java.lang.Object toValueOf(java.lang.Class<T> cls, java.lang.String value) throws java.lang.NoSuchMethodException, java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException, java.lang.Exception
java.lang.NoSuchMethodException
java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
java.lang.Exception
public static <T> java.lang.Object toValuesOf(java.lang.Class<T> cls, java.lang.Class<?> paramClass, java.lang.Object[] values) throws java.lang.NoSuchMethodException, java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException, java.lang.Exception
java.lang.NoSuchMethodException
java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
java.lang.Exception
public static <T> java.lang.Object toValuesOf(java.lang.Class<T> cls, java.lang.String[] values) throws java.lang.NoSuchMethodException, java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException, java.lang.Exception
java.lang.NoSuchMethodException
java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
java.lang.Exception
public static java.lang.Throwable getThrowableCause(java.lang.Throwable e)
public static java.lang.String getThrowableMessage(java.lang.Throwable e)
public static ConfigurationException getThrowableConfigurationException(java.lang.Throwable e)
public static java.util.List<java.lang.Class<?>> getAllInterfaces(java.lang.Class<?> cls)
Copyright © 2013 Dassault Systèmes, All Rights Reserved.