public final class ClassReflection extends Object
| Constructor and Description |
|---|
ClassReflection() |
| Modifier and Type | Method and Description |
|---|---|
static Class |
forName(String name)
Returns the Class object associated with the class or interface with the supplied string name.
|
static Annotation |
getAnnotation(Class c,
Class<? extends Annotation> annotationType)
Returns an
Annotation object reflecting the annotation provided, or null if this class doesn't have such an
annotation. |
static Constructor |
getConstructor(Class c,
Class... parameterTypes)
Returns a
Constructor that represents the public constructor for the supplied class which takes the supplied
parameter types. |
static Constructor |
getDeclaredConstructor(Class c,
Class... parameterTypes)
Returns a
Constructor that represents the constructor for the supplied class which takes the supplied parameter
types. |
static Field |
getField(Class c,
String name)
Returns a
Field that represents the specified public member field for the supplied class. |
static Field[] |
getFields(Class c)
Returns an array of
Field containing the public fields of the class represented by the supplied Class. |
static String |
getSimpleName(Class c)
Returns the simple name of the underlying class as supplied in the source code.
|
static boolean |
isAssignableFrom(Class c1,
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(Class c,
Object obj)
Determines if the supplied Object is assignment-compatible with the object represented by supplied Class.
|
static <T> T |
newInstance(Class<T> c)
Creates a new instance of the class represented by the supplied Class.
|
public static Class forName(String name) throws ReflectionException
ReflectionExceptionpublic static String getSimpleName(Class c)
public static boolean isInstance(Class c, Object obj)
public static boolean isAssignableFrom(Class c1, Class c2)
public static <T> T newInstance(Class<T> c) throws ReflectionException
ReflectionExceptionpublic static Constructor getConstructor(Class c, Class... parameterTypes) throws ReflectionException
Constructor that represents the public constructor for the supplied class which takes the supplied
parameter types.ReflectionExceptionpublic static Constructor getDeclaredConstructor(Class c, Class... parameterTypes) throws ReflectionException
Constructor that represents the constructor for the supplied class which takes the supplied parameter
types.ReflectionExceptionpublic static Field[] getFields(Class c)
Field containing the public fields of the class represented by the supplied Class.public static Field getField(Class c, String name) throws ReflectionException
Field that represents the specified public member field for the supplied class.ReflectionExceptionpublic static Annotation getAnnotation(Class c, Class<? extends 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.Copyright © 2018. All rights reserved.