public final class ClassReflection
extends java.lang.Object
构造器和说明 |
---|
ClassReflection() |
限定符和类型 | 方法和说明 |
---|---|
static java.lang.Class |
forName(java.lang.String name)
Returns the Class object associated with the class or interface with the supplied string name.
|
static Annotation |
getAnnotation(java.lang.Class c,
java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
Returns an
Annotation object reflecting the annotation provided, or null if this class doesn't have such an
annotation. |
static Annotation[] |
getAnnotations(java.lang.Class c)
Returns an array of
Annotation objects reflecting all annotations declared by the supplied class, and inherited
from its superclass. |
static Constructor |
getConstructor(java.lang.Class c,
java.lang.Class... parameterTypes)
Returns a
Constructor that represents the public constructor for the supplied class which takes the supplied
parameter types. |
static Constructor[] |
getConstructors(java.lang.Class c)
Returns an array of
Constructor containing the public constructors of the class represented by the supplied Class. |
static Annotation |
getDeclaredAnnotation(java.lang.Class c,
java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
Returns an
Annotation object reflecting the annotation provided, or null if this class doesn't have such an
annotation. |
static Annotation[] |
getDeclaredAnnotations(java.lang.Class c)
Returns an array of
Annotation objects reflecting all annotations declared by the supplied class, or an empty
array if there are none. |
static Constructor |
getDeclaredConstructor(java.lang.Class c,
java.lang.Class... parameterTypes)
Returns a
Constructor that represents the constructor for the supplied class which takes the supplied parameter
types. |
static Field |
getDeclaredField(java.lang.Class c,
java.lang.String name)
Returns a
Field that represents the specified declared field for the supplied class. |
static Field[] |
getDeclaredFields(java.lang.Class c)
Returns an array of
Field objects reflecting all the fields declared by the supplied class. |
static Method |
getDeclaredMethod(java.lang.Class c,
java.lang.String name,
java.lang.Class... parameterTypes)
Returns a
Method that represents the method declared by the supplied class which takes the supplied parameter types. |
static Method[] |
getDeclaredMethods(java.lang.Class c)
Returns an array of
Method containing the methods declared by the class represented by the supplied Class. |
static Field |
getField(java.lang.Class c,
java.lang.String name)
Returns a
Field that represents the specified public member field for the supplied class. |
static Field[] |
getFields(java.lang.Class c)
Returns an array of
Field containing the public fields of the class represented by the supplied Class. |
static java.lang.Class[] |
getInterfaces(java.lang.Class c) |
static Method |
getMethod(java.lang.Class c,
java.lang.String name,
java.lang.Class... parameterTypes)
Returns a
Method that represents the public member method for the supplied class which takes the supplied parameter
types. |
static Method[] |
getMethods(java.lang.Class c)
Returns an array of
Method containing the public member methods of the class represented by the supplied Class. |
static java.lang.String |
getSimpleName(java.lang.Class c)
Returns the simple name of the underlying class as supplied in the source code.
|
static boolean |
isAnnotationPresent(java.lang.Class c,
java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
Returns true if the supplied class includes an annotation of the given type.
|
static boolean |
isArray(java.lang.Class c)
Determines if the supplied Class object represents an array class.
|
static boolean |
isAssignableFrom(java.lang.Class c1,
java.lang.Class c2)
Determines if the class or interface represented by first Class parameter is either the same as, or is a superclass or
superinterface of, the class or interface represented by the second Class parameter.
|
static boolean |
isInstance(java.lang.Class c,
java.lang.Object obj)
Determines if the supplied Object is assignment-compatible with the object represented by supplied Class.
|
static boolean |
isMemberClass(java.lang.Class c)
Returns true if the class or interface represented by the supplied Class is a member class.
|
static boolean |
isStaticClass(java.lang.Class c)
Returns true if the class or interface represented by the supplied Class is a static class.
|
static <T> T |
newInstance(java.lang.Class<T> c)
Creates a new instance of the class represented by the supplied Class.
|
public static java.lang.Class forName(java.lang.String name) throws ReflectionException
public static java.lang.String getSimpleName(java.lang.Class c)
public static boolean isInstance(java.lang.Class c, java.lang.Object obj)
public static boolean isAssignableFrom(java.lang.Class c1, java.lang.Class c2)
public static boolean isMemberClass(java.lang.Class c)
public static boolean isStaticClass(java.lang.Class c)
public static boolean isArray(java.lang.Class c)
public static <T> T newInstance(java.lang.Class<T> c) throws ReflectionException
public static Constructor[] getConstructors(java.lang.Class c)
Constructor
containing the public constructors of the class represented by the supplied Class.public static Constructor getConstructor(java.lang.Class c, java.lang.Class... parameterTypes) throws ReflectionException
Constructor
that represents the public constructor for the supplied class which takes the supplied
parameter types.public static Constructor getDeclaredConstructor(java.lang.Class c, java.lang.Class... parameterTypes) throws ReflectionException
Constructor
that represents the constructor for the supplied class which takes the supplied parameter
types.public static Method[] getMethods(java.lang.Class c)
Method
containing the public member methods of the class represented by the supplied Class.public static Method getMethod(java.lang.Class c, java.lang.String name, java.lang.Class... parameterTypes) throws ReflectionException
Method
that represents the public member method for the supplied class which takes the supplied parameter
types.public static Method[] getDeclaredMethods(java.lang.Class c)
Method
containing the methods declared by the class represented by the supplied Class.public static Method getDeclaredMethod(java.lang.Class c, java.lang.String name, java.lang.Class... parameterTypes) throws ReflectionException
Method
that represents the method declared by the supplied class which takes the supplied parameter types.public static Field[] getFields(java.lang.Class c)
Field
containing the public fields of the class represented by the supplied Class.public static Field getField(java.lang.Class c, java.lang.String name) throws ReflectionException
Field
that represents the specified public member field for the supplied class.public static Field[] getDeclaredFields(java.lang.Class c)
Field
objects reflecting all the fields declared by the supplied class.public static Field getDeclaredField(java.lang.Class c, java.lang.String name) throws ReflectionException
Field
that represents the specified declared field for the supplied class.public static boolean isAnnotationPresent(java.lang.Class c, java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
public static Annotation[] getAnnotations(java.lang.Class c)
Annotation
objects reflecting all annotations declared by the supplied class, and inherited
from its superclass. Returns an empty array if there are none.public static Annotation getAnnotation(java.lang.Class c, java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
Annotation
object reflecting the annotation provided, or null if this class doesn't have such an
annotation. This is a convenience function if the caller knows already which annotation type he's looking for.public static Annotation[] getDeclaredAnnotations(java.lang.Class c)
Annotation
objects reflecting all annotations declared by the supplied class, or an empty
array if there are none. Does not include inherited annotations.public static Annotation getDeclaredAnnotation(java.lang.Class c, java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
Annotation
object reflecting the annotation provided, or null if this class doesn't have such an
annotation. This is a convenience function if the caller knows already which annotation type he's looking for.public static java.lang.Class[] getInterfaces(java.lang.Class c)