APIdia Launch Partner
Top Description Constructors Methods
com.badlogic.gdx.utils.reflect

public final Class ClassReflection

extends Object
Class Inheritance
Imports
java.lang.reflect.Modifier

Utilities for Class reflection.
Author
nexsoftware

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static Class<T>
forName(String name)

Returns the Class object associated with the class or interface with the supplied string name.

public static Annotation
getAnnotation(Class<T> c, Class<? extends Annotation> annotationType)

Returns an Annotation object reflecting the annotation provided, or null if this class doesn't have such an annotation.

public static Annotation[]
getAnnotations(Class<T> c)

Returns an array of Annotation objects reflecting all annotations declared by the supplied class, and inherited from its superclass.

public static Class<T>
getComponentType(Class<T> c)

Returns the Class representing the component type of an array.

public static Constructor
getConstructor(Class<T> c, Class<T>... parameterTypes)

Returns a Constructor that represents the public constructor for the supplied class which takes the supplied parameter types.

public static Constructor[]
getConstructors(Class<T> c)

Returns an array of Constructor containing the public constructors of the class represented by the supplied Class.

public static Annotation
getDeclaredAnnotation(Class<T> c, Class<? extends Annotation> annotationType)

Returns an Annotation object reflecting the annotation provided, or null if this class doesn't have such an annotation.

public static Annotation[]
getDeclaredAnnotations(Class<T> c)

Returns an array of Annotation objects reflecting all annotations declared by the supplied class, or an empty array if there are none.

public static Constructor
getDeclaredConstructor(Class<T> c, Class<T>... parameterTypes)

Returns a Constructor that represents the constructor for the supplied class which takes the supplied parameter types.

public static Field
getDeclaredField(Class<T> c, String name)

Returns a Field that represents the specified declared field for the supplied class.

public static Field[]
getDeclaredFields(Class<T> c)

Returns an array of Field objects reflecting all the fields declared by the supplied class.

public static Method
getDeclaredMethod(Class<T> c, String name, Class<T>... parameterTypes)

Returns a Method that represents the method declared by the supplied class which takes the supplied parameter types.

public static Method[]
getDeclaredMethods(Class<T> c)

Returns an array of Method containing the methods declared by the class represented by the supplied Class.

public static Object[]
getEnumConstants(Class<T> c)

Returns the elements of this enum class or null if this Class object does not represent an enum type.

public static Field
getField(Class<T> c, String name)

Returns a Field that represents the specified public member field for the supplied class.

public static Field[]
getFields(Class<T> c)

Returns an array of Field containing the public fields of the class represented by the supplied Class.

public static Class<T>[]
public static Method
getMethod(Class<T> c, String name, Class<T>... parameterTypes)

Returns a Method that represents the public member method for the supplied class which takes the supplied parameter types.

public static Method[]
getMethods(Class<T> c)

Returns an array of Method containing the public member methods of the class represented by the supplied Class.

public static String
getSimpleName(Class<T> c)

Returns the simple name of the underlying class as supplied in the source code.

public static boolean
isAbstract(Class<T> c)

Determines if the supplied Class object represents an abstract type.

public static boolean
isAnnotation(Class<T> c)

Determines if the supplied Class object represents an annotation type.

public static boolean
isAnnotationPresent(Class<T> c, Class<? extends Annotation> annotationType)

Returns true if the supplied class includes an annotation of the given type.

public static boolean
isArray(Class<T> c)

Determines if the supplied Class object represents an array class.

public static boolean
isAssignableFrom(Class<T> c1, Class<T> 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.

public static boolean
isEnum(Class<T> c)

Determines if the supplied Class object represents an enum type.

public static boolean
isInstance(Class<T> c, Object obj)

Determines if the supplied Object is assignment-compatible with the object represented by supplied Class.

public static boolean
isInterface(Class<T> c)

Determines if the supplied Class object represents an interface type.

public static boolean
isMemberClass(Class<T> c)

Returns true if the class or interface represented by the supplied Class is a member class.

public static boolean
isPrimitive(Class<T> c)

Determines if the supplied Class object represents a primitive type.

public static boolean
isStaticClass(Class<T> c)

Returns true if the class or interface represented by the supplied Class is a static class.

public static <T> T
newInstance(Class<T> c)

Creates a new instance of the class represented by the supplied Class.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

ClassReflectionback to summary
public ClassReflection()

Method Detail

forNameback to summary
public static Class<T> forName(String name) throws ReflectionException

Returns the Class object associated with the class or interface with the supplied string name.

getAnnotationback to summary
public static Annotation getAnnotation(Class<T> c, Class<? extends Annotation> annotationType)

Returns an 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.

getAnnotationsback to summary
public static Annotation[] getAnnotations(Class<T> c)

Returns an array of Annotation objects reflecting all annotations declared by the supplied class, and inherited from its superclass. Returns an empty array if there are none.

getComponentTypeback to summary
public static Class<T> getComponentType(Class<T> c)

Returns the Class representing the component type of an array. If this class does not represent an array class this method returns null.

getConstructorback to summary
public static Constructor getConstructor(Class<T> c, Class<T>... parameterTypes) throws ReflectionException

Returns a Constructor that represents the public constructor for the supplied class which takes the supplied parameter types.

getConstructorsback to summary
public static Constructor[] getConstructors(Class<T> c)

Returns an array of Constructor containing the public constructors of the class represented by the supplied Class.

getDeclaredAnnotationback to summary
public static Annotation getDeclaredAnnotation(Class<T> c, Class<? extends Annotation> annotationType)

Returns an 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.

getDeclaredAnnotationsback to summary
public static Annotation[] getDeclaredAnnotations(Class<T> c)

Returns an array of Annotation objects reflecting all annotations declared by the supplied class, or an empty array if there are none. Does not include inherited annotations.

getDeclaredConstructorback to summary
public static Constructor getDeclaredConstructor(Class<T> c, Class<T>... parameterTypes) throws ReflectionException

Returns a Constructor that represents the constructor for the supplied class which takes the supplied parameter types.

getDeclaredFieldback to summary
public static Field getDeclaredField(Class<T> c, String name) throws ReflectionException

Returns a Field that represents the specified declared field for the supplied class.

getDeclaredFieldsback to summary
public static Field[] getDeclaredFields(Class<T> c)

Returns an array of Field objects reflecting all the fields declared by the supplied class.

getDeclaredMethodback to summary
public static Method getDeclaredMethod(Class<T> c, String name, Class<T>... parameterTypes) throws ReflectionException

Returns a Method that represents the method declared by the supplied class which takes the supplied parameter types.

getDeclaredMethodsback to summary
public static Method[] getDeclaredMethods(Class<T> c)

Returns an array of Method containing the methods declared by the class represented by the supplied Class.

getEnumConstantsback to summary
public static Object[] getEnumConstants(Class<T> c)

Returns the elements of this enum class or null if this Class object does not represent an enum type.

getFieldback to summary
public static Field getField(Class<T> c, String name) throws ReflectionException

Returns a Field that represents the specified public member field for the supplied class.

getFieldsback to summary
public static Field[] getFields(Class<T> c)

Returns an array of Field containing the public fields of the class represented by the supplied Class.

getInterfacesback to summary
public static Class<T>[] getInterfaces(Class<T> c)
getMethodback to summary
public static Method getMethod(Class<T> c, String name, Class<T>... parameterTypes) throws ReflectionException

Returns a Method that represents the public member method for the supplied class which takes the supplied parameter types.

getMethodsback to summary
public static Method[] getMethods(Class<T> c)

Returns an array of Method containing the public member methods of the class represented by the supplied Class.

getSimpleNameback to summary
public static String getSimpleName(Class<T> c)

Returns the simple name of the underlying class as supplied in the source code.

isAbstractback to summary
public static boolean isAbstract(Class<T> c)

Determines if the supplied Class object represents an abstract type.

isAnnotationback to summary
public static boolean isAnnotation(Class<T> c)

Determines if the supplied Class object represents an annotation type.

isAnnotationPresentback to summary
public static boolean isAnnotationPresent(Class<T> c, Class<? extends Annotation> annotationType)

Returns true if the supplied class includes an annotation of the given type.

isArrayback to summary
public static boolean isArray(Class<T> c)

Determines if the supplied Class object represents an array class.

isAssignableFromback to summary
public static boolean isAssignableFrom(Class<T> c1, Class<T> 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.

isEnumback to summary
public static boolean isEnum(Class<T> c)

Determines if the supplied Class object represents an enum type.

isInstanceback to summary
public static boolean isInstance(Class<T> c, Object obj)

Determines if the supplied Object is assignment-compatible with the object represented by supplied Class.

isInterfaceback to summary
public static boolean isInterface(Class<T> c)

Determines if the supplied Class object represents an interface type.

isMemberClassback to summary
public static boolean isMemberClass(Class<T> c)

Returns true if the class or interface represented by the supplied Class is a member class.

isPrimitiveback to summary
public static boolean isPrimitive(Class<T> c)

Determines if the supplied Class object represents a primitive type.

isStaticClassback to summary
public static boolean isStaticClass(Class<T> c)

Returns true if the class or interface represented by the supplied Class is a static class.

newInstanceback to summary
public static <T> T newInstance(Class<T> c) throws ReflectionException

Creates a new instance of the class represented by the supplied Class.