public abstract class BeanUtils
extends java.lang.Object
Title: BeanUtils.java
Description:
bboss workgroup
Copyright (c) 2008
| 构造器和说明 |
|---|
BeanUtils() |
| 限定符和类型 | 方法和说明 |
|---|---|
static java.lang.reflect.Method |
findDeclaredMethod(java.lang.Class clazz,
java.lang.String methodName,
java.lang.Class[] paramTypes)
Find a method with the given method name and the given parameter types,
declared on the given class or one of its superclasses.
|
static java.lang.reflect.Method |
findDeclaredMethodWithMinimalParameters(java.lang.Class clazz,
java.lang.String methodName)
Find a method with the given method name and minimal parameters (best case: none),
declared on the given class or one of its superclasses.
|
static java.lang.reflect.Method |
findMethod(java.lang.Class clazz,
java.lang.String methodName,
java.lang.Class[] paramTypes)
Find a method with the given method name and the given parameter types,
declared on the given class or one of its superclasses.
|
static java.lang.reflect.Method |
findMethodWithMinimalParameters(java.lang.Class clazz,
java.lang.String methodName)
Find a method with the given method name and minimal parameters (best case: none),
declared on the given class or one of its superclasses.
|
static MethodParameter |
getWriteMethodParameter(java.beans.PropertyDescriptor pd)
Obtain a new MethodParameter object for the write method of the
specified property.
|
static <T> T |
instantiate(java.lang.Class<T> clazz)
Convenience method to instantiate a class using its no-arg constructor.
|
static <T> T |
instantiateClass(java.lang.Class<T> clazz)
Convenience method to instantiate a class using its no-arg constructor.
|
static <T> T |
instantiateClass(java.lang.Class<T> type,
java.lang.reflect.Constructor ctor,
java.lang.Object[] args)
Convenience method to instantiate a class using the given constructor.
|
static java.lang.Object |
instantiateClass(java.lang.reflect.Constructor ctor,
java.lang.Object[] args)
Convenience method to instantiate a class using the given constructor.
|
static java.lang.Object |
instantiateClass(java.lang.String clazz)
Convenience method to instantiate a class using its no-arg constructor.
|
static boolean |
isAssignable(java.lang.Class targetType,
java.lang.Class valueType)
Determine if the given target type is assignable from the given value
type, assuming setting by reflection.
|
static boolean |
isAssignable(java.lang.Class type,
java.lang.Object value)
已过时。
as of Bboss 2.0, in favor of
ClassUtils.isAssignableValue |
static boolean |
isSimpleProperty(java.lang.Class clazz)
Check if the given type represents a "simple" property:
a primitive, a String or other CharSequence, a Number, a Date,
a URI, a URL, a Locale, a Class, or a corresponding array.
|
static boolean |
isSimpleValueType(java.lang.Class clazz)
Check if the given type represents a "simple" value type:
a primitive, a String or other CharSequence, a Number, a Date,
a URI, a URL, a Locale or a Class.
|
public static <T> T instantiateClass(java.lang.Class<T> clazz)
throws BeanInstantiationException
Note that this method tries to set the constructor accessible if given a non-accessible (that is, non-public) constructor.
clazz - class to instantiateBeanInstantiationException - if the bean cannot be instantiatedpublic static <T> T instantiate(java.lang.Class<T> clazz)
throws BeanInstantiationException
clazz - class to instantiateBeanInstantiationException - if the bean cannot be instantiatedpublic static java.lang.Object instantiateClass(java.lang.String clazz)
throws BeanInstantiationException
Note that this method tries to set the constructor accessible if given a non-accessible (that is, non-public) constructor.
clazz - class to instantiateBeanInstantiationException - if the bean cannot be instantiatedpublic static java.lang.Object instantiateClass(java.lang.reflect.Constructor ctor,
java.lang.Object[] args)
throws BeanInstantiationException
Note that this method tries to set the constructor accessible if given a non-accessible (that is, non-public) constructor.
ctor - the constructor to instantiateargs - the constructor arguments to applyBeanInstantiationException - if the bean cannot be instantiatedpublic static <T> T instantiateClass(java.lang.Class<T> type,
java.lang.reflect.Constructor ctor,
java.lang.Object[] args)
throws BeanInstantiationException
Note that this method tries to set the constructor accessible if given a non-accessible (that is, non-public) constructor.
ctor - the constructor to instantiateargs - the constructor arguments to applyBeanInstantiationException - if the bean cannot be instantiatedpublic static java.lang.reflect.Method findMethod(java.lang.Class clazz,
java.lang.String methodName,
java.lang.Class[] paramTypes)
Checks Class.getMethod first, falling back to
findDeclaredMethod. This allows to find public methods
without issues even in environments with restricted Java security settings.
clazz - the class to checkmethodName - the name of the method to findparamTypes - the parameter types of the method to findnull if not foundClass.getMethod(java.lang.String, java.lang.Class<?>...),
findDeclaredMethod(java.lang.Class, java.lang.String, java.lang.Class[])public static java.lang.reflect.Method findDeclaredMethod(java.lang.Class clazz,
java.lang.String methodName,
java.lang.Class[] paramTypes)
Checks Class.getDeclaredMethod, cascading upwards to all superclasses.
clazz - the class to checkmethodName - the name of the method to findparamTypes - the parameter types of the method to findnull if not foundClass.getDeclaredMethod(java.lang.String, java.lang.Class<?>...)public static java.lang.reflect.Method findMethodWithMinimalParameters(java.lang.Class clazz,
java.lang.String methodName)
throws java.lang.IllegalArgumentException
Checks Class.getMethods first, falling back to
findDeclaredMethodWithMinimalParameters. This allows to find public
methods without issues even in environments with restricted Java security settings.
clazz - the class to checkmethodName - the name of the method to findnull if not foundjava.lang.IllegalArgumentException - if methods of the given name were found but
could not be resolved to a unique method with minimal parametersClass.getMethods(),
findDeclaredMethodWithMinimalParameters(java.lang.Class, java.lang.String)public static java.lang.reflect.Method findDeclaredMethodWithMinimalParameters(java.lang.Class clazz,
java.lang.String methodName)
throws java.lang.IllegalArgumentException
Checks Class.getDeclaredMethods, cascading upwards to all superclasses.
clazz - the class to checkmethodName - the name of the method to findnull if not foundjava.lang.IllegalArgumentException - if methods of the given name were found but
could not be resolved to a unique method with minimal parametersClass.getDeclaredMethods()public static boolean isSimpleProperty(java.lang.Class clazz)
Used to determine properties to check for a "simple" dependency-check.
clazz - the type to checkpublic static boolean isSimpleValueType(java.lang.Class clazz)
clazz - the type to checkpublic static boolean isAssignable(java.lang.Class targetType,
java.lang.Class valueType)
targetType - the target typevalueType - the value type that should be assigned to the target typepublic static boolean isAssignable(java.lang.Class type,
java.lang.Object value)
ClassUtils.isAssignableValuetype - the target typevalue - the value that should be assigned to the typeClassUtils.isAssignableValue(Class, Object)public static MethodParameter getWriteMethodParameter(java.beans.PropertyDescriptor pd)
pd - the PropertyDescriptor for the property