com.badlogic.gdx.utils.reflect
Class ClassReflection

java.lang.Object
  extended by com.badlogic.gdx.utils.reflect.ClassReflection

public final class ClassReflection
extends Object

Utilities for Class reflection.

Author:
nexsoftware

Constructor Summary
ClassReflection()
           
 
Method Summary
static Class forName(String name)
          Returns the Class object associated with the class or interface with the supplied string name.
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[] getConstructors(Class c)
          Returns an array of Constructor containing the public constructors of the class represented by the supplied Class.
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 getDeclaredField(Class c, String name)
          Returns a Field that represents the specified declared field for the supplied class.
static Field[] getDeclaredFields(Class c)
          Returns an array of Field objects reflecting all the fields declared by the supplied class.
static Method getDeclaredMethod(Class c, String name, Class... parameterTypes)
          Returns a Method that represents the method declared by the supplied class which takes the supplied parameter types.
static Method[] getDeclaredMethods(Class c)
          Returns an array of Method containing the methods declared by the class represented by the supplied Class.
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 Method getMethod(Class c, String name, Class... parameterTypes)
          Returns a Method that represents the public member method for the supplied class which takes the supplied parameter types.
static Method[] getMethods(Class c)
          Returns an array of Method containing the public member methods 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 boolean isMemberClass(Class c)
          Returns true if the class or interface represented by the supplied Class is a member class.
static boolean isStaticClass(Class c)
          Returns true if the class or interface represented by the supplied Class is a static class.
static
<T> T
newInstance(Class<T> c)
          Creates a new instance of the class represented by the supplied Class.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClassReflection

public ClassReflection()
Method Detail

forName

public static Class forName(String name)
                     throws ReflectionException
Returns the Class object associated with the class or interface with the supplied string name.

Throws:
ReflectionException

getSimpleName

public static String getSimpleName(Class c)
Returns the simple name of the underlying class as supplied in the source code.


isInstance

public static boolean isInstance(Class c,
                                 Object obj)
Determines if the supplied Object is assignment-compatible with the object represented by supplied Class.


isAssignableFrom

public 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.


isMemberClass

public static boolean isMemberClass(Class c)
Returns true if the class or interface represented by the supplied Class is a member class.


isStaticClass

public static boolean isStaticClass(Class c)
Returns true if the class or interface represented by the supplied Class is a static class.


newInstance

public static <T> T newInstance(Class<T> c)
                     throws ReflectionException
Creates a new instance of the class represented by the supplied Class.

Throws:
ReflectionException

getConstructors

public static Constructor[] getConstructors(Class c)
Returns an array of Constructor containing the public constructors of the class represented by the supplied Class.


getConstructor

public static Constructor getConstructor(Class c,
                                         Class... parameterTypes)
                                  throws ReflectionException
Returns a Constructor that represents the public constructor for the supplied class which takes the supplied parameter types.

Throws:
ReflectionException

getDeclaredConstructor

public static Constructor getDeclaredConstructor(Class c,
                                                 Class... parameterTypes)
                                          throws ReflectionException
Returns a Constructor that represents the constructor for the supplied class which takes the supplied parameter types.

Throws:
ReflectionException

getMethods

public static Method[] getMethods(Class c)
Returns an array of Method containing the public member methods of the class represented by the supplied Class.


getMethod

public static Method getMethod(Class c,
                               String name,
                               Class... parameterTypes)
                        throws ReflectionException
Returns a Method that represents the public member method for the supplied class which takes the supplied parameter types.

Throws:
ReflectionException

getDeclaredMethods

public static Method[] getDeclaredMethods(Class c)
Returns an array of Method containing the methods declared by the class represented by the supplied Class.


getDeclaredMethod

public static Method getDeclaredMethod(Class c,
                                       String name,
                                       Class... parameterTypes)
                                throws ReflectionException
Returns a Method that represents the method declared by the supplied class which takes the supplied parameter types.

Throws:
ReflectionException

getFields

public static Field[] getFields(Class c)
Returns an array of Field containing the public fields of the class represented by the supplied Class.


getField

public static Field getField(Class c,
                             String name)
                      throws ReflectionException
Returns a Field that represents the specified public member field for the supplied class.

Throws:
ReflectionException

getDeclaredFields

public static Field[] getDeclaredFields(Class c)
Returns an array of Field objects reflecting all the fields declared by the supplied class.


getDeclaredField

public static Field getDeclaredField(Class c,
                                     String name)
                              throws ReflectionException
Returns a Field that represents the specified declared field for the supplied class.

Throws:
ReflectionException


Copyright © 2013. All Rights Reserved.