public final class ReflectHelper extends Object
| 限定符和类型 | 字段和说明 |
|---|---|
static Class[] |
NO_PARAM_SIGNATURE |
static Object[] |
NO_PARAMS |
static Class[] |
SINGLE_OBJECT_PARAM_SIGNATURE |
| 限定符和类型 | 方法和说明 |
|---|---|
static Class |
classForName(String name)
已过时。
|
static Class |
classForName(String name,
Class caller)
Perform resolution of a class name.
|
static Method |
extractEqualsMethod(Class clazz)
Encapsulation of getting hold of a class's
equals method. |
static Method |
extractHashCodeMethod(Class clazz)
Encapsulation of getting hold of a class's
hashCode method. |
static Field |
findField(Class containerClass,
String propertyName) |
static Method |
findGetterMethod(Class containerClass,
String propertyName) |
static Method |
findSetterMethod(Class containerClass,
String propertyName,
Class propertyType) |
static <T> Constructor<T> |
getDefaultConstructor(Class<T> clazz)
Retrieve the default (no arg) constructor from the given class.
|
static Method |
getMethod(Class clazz,
Method method) |
static boolean |
implementsInterface(Class clazz,
Class intf)
Determine if the given class implements the given interface.
|
static boolean |
isAbstractClass(Class clazz)
Determine if the given class is declared abstract.
|
static boolean |
isFinalClass(Class clazz)
Determine is the given class is declared final.
|
static boolean |
isPublic(Class clazz,
Member member)
Is this member publicly accessible.
|
static boolean |
overridesEquals(Class clazz)
Determine if the given class defines an
Object.equals(java.lang.Object) override. |
static boolean |
overridesHashCode(Class clazz)
Determine if the given class defines a
Object.hashCode() override. |
public static final Class[] NO_PARAM_SIGNATURE
public static final Object[] NO_PARAMS
public static final Class[] SINGLE_OBJECT_PARAM_SIGNATURE
public static Method extractEqualsMethod(Class clazz) throws NoSuchMethodException
equals method.clazz - The class from which to extract the equals method.NoSuchMethodException - Should indicate an attempt to extract equals method from interface.public static Method extractHashCodeMethod(Class clazz) throws NoSuchMethodException
hashCode method.clazz - The class from which to extract the hashCode method.NoSuchMethodException - Should indicate an attempt to extract hashCode method from interface.public static boolean overridesEquals(Class clazz)
Object.equals(java.lang.Object) override.clazz - The class to checkpublic static boolean overridesHashCode(Class clazz)
Object.hashCode() override.clazz - The class to checkpublic static boolean implementsInterface(Class clazz, Class intf)
clazz - The class to checkintf - The interface to check it against.public static Class classForName(String name, Class caller) throws ClassNotFoundException
Class.forName(String, boolean, ClassLoader) using the caller's classloadername - The class namecaller - The class from which this call originated (in order to access that class's loader).ClassNotFoundException - From Class.forName(String, boolean, ClassLoader).@Deprecated public static Class classForName(String name) throws ClassNotFoundException
classForName(String, Class) except that here we delegate to
Class.forName(String) if the context classloader lookup is unsuccessful.name - The class nameClassNotFoundException - From Class.forName(String).public static boolean isPublic(Class clazz, Member member)
clazz - The class which defines the membermember - The memeber.public static <T> Constructor<T> getDefaultConstructor(Class<T> clazz) throws PropertyNotFoundException
clazz - The class for which to retrieve the default ctor.PropertyNotFoundException - Indicates there was not publicly accessible, no-arg constructor (todo : why PropertyNotFoundException???)public static boolean isAbstractClass(Class clazz)
clazz - The class to check.public static boolean isFinalClass(Class clazz)
clazz - The class to check.Copyright © 2019. All rights reserved.