com.alee.utils
Class ReflectUtils

java.lang.Object
  extended by com.alee.utils.ReflectUtils

public final class ReflectUtils
extends java.lang.Object

This class provides a set of utilities to simplify work with Reflection API. There is also a few methods to retrieve full JAR archive structure.

Author:
Mikle Garin

Constructor Summary
ReflectUtils()
           
 
Method Summary
static void applyFieldValue(java.lang.Object object, java.lang.String field, java.lang.Object value)
          Applies specified value to object field.
static boolean applyFieldValueSafely(java.lang.Object object, java.lang.String field, java.lang.Object value)
          Applies specified value to object field.
static
<T> T
callMethod(java.lang.Object object, java.lang.String methodName, java.lang.Object... arguments)
          Calls object's method with the specified name and arguments.
static
<T> java.util.List<T>
callMethods(java.util.List objects, java.lang.String methodName, java.lang.Object... arguments)
          Returns list of results returned by called methods.
static java.lang.Object[] callMethods(java.lang.Object[] objects, java.lang.String methodName, java.lang.Object... arguments)
          Returns an array of results returned by called methods.
static
<T> T
callMethodSafely(java.lang.Object object, java.lang.String methodName, java.lang.Object... arguments)
          Returns result given by called method.
static
<T> java.util.List<T>
callMethodsSafely(java.util.List objects, java.lang.String methodName, java.lang.Object... arguments)
          Returns list of results returned by called methods.
static java.lang.Object[] callMethodsSafely(java.lang.Object[] objects, java.lang.String methodName, java.lang.Object... arguments)
          Returns an array of results returned by called methods.
static
<T> T
callStaticMethod(java.lang.Class theClass, java.lang.String methodName, java.lang.Object... arguments)
          Returns result of called static method.
static
<T> T
callStaticMethod(java.lang.String canonicalClassName, java.lang.String methodName, java.lang.Object... arguments)
          Returns result of called static method.
static
<T> T
callStaticMethodSafely(java.lang.Class theClass, java.lang.String methodName, java.lang.Object... arguments)
          Returns result of called static method.
static
<T> T
callStaticMethodSafely(java.lang.String canonicalClassName, java.lang.String methodName, java.lang.Object... arguments)
          Returns result of called static method.
static
<T extends java.lang.Cloneable>
T
clone(T object)
          Returns cloned object.
static
<T extends java.lang.Cloneable>
T
cloneSafely(T object)
          Returns cloned object.
static boolean containsInClassOrSuperclassName(java.lang.Class theClass, java.lang.String text)
          Returns whether one of superclasses contains specified text in its name or not.
static
<T> T
createInstance(java.lang.Class theClass, java.lang.Object... arguments)
          Returns newly created class instance.
static
<T> T
createInstance(java.lang.String canonicalClassName, java.lang.Object... arguments)
          Returns newly created class instance.
static
<T> T
createInstanceSafely(java.lang.Class theClass, java.lang.Object... arguments)
          Returns newly created class instance.
static
<T> T
createInstanceSafely(java.lang.String canonicalClassName, java.lang.Object... arguments)
          Returns newly created class instance.
static java.lang.Class getCallerClass()
          Returns method caller class.
static
<T> java.lang.Class<T>
getClass(java.lang.String canonicalName)
          Returns class for the specified canonical name.
static java.lang.String getClassFileName(java.lang.Class classType)
          Returns class name with ".class" extension in the end.
static java.lang.String getClassFileName(java.lang.Object classObject)
          Returns class name with ".class" extension in the end.
static java.lang.String getClassName(java.lang.Class classType)
          Returns class name.
static java.lang.String getClassName(java.lang.Object classObject)
          Returns class name.
static java.lang.String[] getClassPackages(java.lang.Class classType)
          Returns class packages.
static java.lang.String[] getClassPackages(java.lang.Object classObject)
          Returns class packages.
static java.lang.Class getClassSafely(java.lang.String canonicalName)
          Returns class for the specified canonical name.
static java.lang.Class[] getClassTypes(java.lang.Object[] arguments)
          Returns an array of argument class types.
static java.lang.reflect.Constructor getConstructor(java.lang.Class theClass, java.lang.Class... parameterTypes)
          Returns class constructor for the specified argument types.
static java.lang.reflect.Field getField(java.lang.Class classType, java.lang.String fieldName)
          Returns specified class field.
static java.lang.reflect.Method getFieldGetter(java.lang.Class aClass, java.lang.String field)
          Returns field getter methor by popular method naming pattern.
static java.lang.reflect.Method getFieldGetter(java.lang.Object object, java.lang.String field)
          Returns field getter methor by popular method naming pattern.
static java.lang.reflect.Field getFieldImpl(java.lang.Class classType, java.lang.String fieldName)
          Returns specified class field.
static java.lang.reflect.Field getFieldSafely(java.lang.Class classType, java.lang.String fieldName)
          Returns specified class field.
static java.lang.Class<?> getFieldType(java.lang.Class classType, java.lang.String fieldName)
          Returns specified class field's type.
static java.lang.Class<?> getFieldTypeSafely(java.lang.Class classType, java.lang.String fieldName)
          Returns specified class field's type.
static java.lang.String getGetterMethodName(java.lang.String field)
          Returns getter method name for the specified field.
static java.lang.Class getInnerClass(java.lang.Class fromClass, java.lang.String innerClassName)
          Returns inner class with the specified name.
static java.lang.String getIsGetterMethodName(java.lang.String field)
          Returns "is" getter method name for the specified field.
static java.io.File getJarLocationFile(java.lang.Class jarClass)
          Returns JAR location File for the specified class.
static java.net.URL getJarLocationURL(java.lang.Class jarClass)
          Returns JAR location URL for the specified class.
static JarStructure getJarStructure(java.lang.Class jarClass)
          Returns JAR archive structure.
static JarStructure getJarStructure(java.lang.Class jarClass, java.util.List<java.lang.String> allowedExtensions, java.util.List<java.lang.String> allowedPackgages)
          Returns JAR archive structure.
static JarStructure getJarStructure(java.lang.Class jarClass, java.util.List<java.lang.String> allowedExtensions, java.util.List<java.lang.String> allowedPackgages, FileDownloadListener listener)
          Returns JAR archive structure.
static java.lang.String getJavaClassName(java.lang.Class classType)
          Returns class name with ".java" extension in the end.
static java.lang.String getJavaClassName(java.lang.Object classObject)
          Returns class name with ".java" extension in the end.
static java.lang.reflect.Method getMethod(java.lang.Class aClass, java.lang.String methodName, java.lang.Object... arguments)
          Returns object's method with the specified name and arguments.
static java.lang.reflect.Method getMethod(java.lang.Object object, java.lang.String methodName, java.lang.Object... arguments)
          Returns object's method with the specified name and arguments.
protected static java.lang.reflect.Method getMethodImpl(java.lang.Class aClass, java.lang.String methodName, java.lang.Object[] arguments)
          Returns object's method with the specified name and arguments.
static java.lang.reflect.Method getMethodSafely(java.lang.Class aClass, java.lang.String methodName, java.lang.Object... arguments)
          Returns object's method with the specified name and arguments.
static java.lang.reflect.Method getMethodSafely(java.lang.Object object, java.lang.String methodName, java.lang.Object... arguments)
          Calls object's method with the specified name and arguments.
static java.lang.String[] getPackages(java.lang.String packageName)
          Returns packages names.
static java.lang.String getSetterMethodName(java.lang.String field)
          Returns setter method name for the specified field.
static
<T> T
getStaticFieldValue(java.lang.Class classType, java.lang.String fieldName)
          Returns static field value from the specified class.
static
<T> T
getStaticFieldValueSafely(java.lang.Class classType, java.lang.String fieldName)
          Returns static field value from the specified class.
static boolean isAssignable(java.lang.Class type, java.lang.Class from)
          Returns whether first type is assignable from second one or not.
static java.lang.Class loadClass(java.lang.String canonicalClassName)
          Returns class loaded for the specified canonical class name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ReflectUtils

public ReflectUtils()
Method Detail

getFieldTypeSafely

public static java.lang.Class<?> getFieldTypeSafely(java.lang.Class classType,
                                                    java.lang.String fieldName)
Returns specified class field's type. This method will also look for the field in super-classes if any exist.

Parameters:
classType - type of the class where field can be located
fieldName - field name
Returns:
specified class field's type

getFieldType

public static java.lang.Class<?> getFieldType(java.lang.Class classType,
                                              java.lang.String fieldName)
                                       throws java.lang.NoSuchFieldException
Returns specified class field's type. This method will also look for the field in super-classes if any exist.

Parameters:
classType - type of the class where field can be located
fieldName - field name
Returns:
specified class field's type
Throws:
java.lang.NoSuchFieldException

getFieldSafely

public static java.lang.reflect.Field getFieldSafely(java.lang.Class classType,
                                                     java.lang.String fieldName)
                                              throws java.lang.NoSuchFieldException
Returns specified class field. This method will also look for the field in super-classes if any exist.

Parameters:
classType - type of the class where field can be located
fieldName - field name
Returns:
specified class field
Throws:
java.lang.NoSuchFieldException

getField

public static java.lang.reflect.Field getField(java.lang.Class classType,
                                               java.lang.String fieldName)
                                        throws java.lang.NoSuchFieldException
Returns specified class field. This method will also look for the field in super-classes if any exist.

Parameters:
classType - type of the class where field can be located
fieldName - field name
Returns:
specified class field
Throws:
java.lang.NoSuchFieldException

getFieldImpl

public static java.lang.reflect.Field getFieldImpl(java.lang.Class classType,
                                                   java.lang.String fieldName)
                                            throws java.lang.NoSuchFieldException
Returns specified class field. This method will also look for the field in super-classes if any exist.

Parameters:
classType - type of the class where field can be located
fieldName - field name
Returns:
specified class field
Throws:
java.lang.NoSuchFieldException

applyFieldValueSafely

public static boolean applyFieldValueSafely(java.lang.Object object,
                                            java.lang.String field,
                                            java.lang.Object value)
Applies specified value to object field. This method allows to access and modify even private object fields.

Parameters:
object - object instance
field - object field
value - field value
Returns:
true if value was applied successfully, false otherwise

applyFieldValue

public static void applyFieldValue(java.lang.Object object,
                                   java.lang.String field,
                                   java.lang.Object value)
                            throws java.lang.IllegalAccessException,
                                   java.lang.NoSuchFieldException
Applies specified value to object field. This method allows to access and modify even private object fields.

Parameters:
object - object instance
field - object field
value - field value
Throws:
java.lang.IllegalAccessException
java.lang.NoSuchFieldException

getClassSafely

public static java.lang.Class getClassSafely(java.lang.String canonicalName)
Returns class for the specified canonical name.

Parameters:
canonicalName - class canonical name
Returns:
class for the specified canonical name

getClass

public static <T> java.lang.Class<T> getClass(java.lang.String canonicalName)
                                   throws java.lang.ClassNotFoundException
Returns class for the specified canonical name.

Parameters:
canonicalName - class canonical name
Returns:
class for the specified canonical name
Throws:
java.lang.ClassNotFoundException

getJarStructure

public static JarStructure getJarStructure(java.lang.Class jarClass)
Returns JAR archive structure.

Parameters:
jarClass - any class within the JAR
Returns:
JAR archive structure

getJarStructure

public static JarStructure getJarStructure(java.lang.Class jarClass,
                                           java.util.List<java.lang.String> allowedExtensions,
                                           java.util.List<java.lang.String> allowedPackgages)
Returns JAR archive structure.

Parameters:
jarClass - any class within the JAR
allowedExtensions - list of extension filters
allowedPackgages - list of allowed packages
Returns:
JAR archive structure

getJarStructure

public static JarStructure getJarStructure(java.lang.Class jarClass,
                                           java.util.List<java.lang.String> allowedExtensions,
                                           java.util.List<java.lang.String> allowedPackgages,
                                           FileDownloadListener listener)
Returns JAR archive structure.

Parameters:
jarClass - any class within the JAR
allowedExtensions - list of extension filters
allowedPackgages - list of allowed packages
listener - jar download listener
Returns:
JAR archive structure

getJarLocationURL

public static java.net.URL getJarLocationURL(java.lang.Class jarClass)
Returns JAR location URL for the specified class.

Parameters:
jarClass - any class from that JAR
Returns:
JAR location URL

getJarLocationFile

public static java.io.File getJarLocationFile(java.lang.Class jarClass)
Returns JAR location File for the specified class.

Parameters:
jarClass - any class from that JAR
Returns:
JAR location File

getCallerClass

public static java.lang.Class getCallerClass()
Returns method caller class. It is not recommended to use this method anywhere but in debugging.

Returns:
method caller class

getJavaClassName

public static java.lang.String getJavaClassName(java.lang.Object classObject)
Returns class name with ".java" extension in the end.

Parameters:
classObject - object of class type
Returns:
class name with ".java" extension in the end

getJavaClassName

public static java.lang.String getJavaClassName(java.lang.Class classType)
Returns class name with ".java" extension in the end.

Parameters:
classType - class type
Returns:
class name with ".java" extension in the end

getClassFileName

public static java.lang.String getClassFileName(java.lang.Object classObject)
Returns class name with ".class" extension in the end.

Parameters:
classObject - object of class type
Returns:
class name with ".class" extension in the end

getClassFileName

public static java.lang.String getClassFileName(java.lang.Class classType)
Returns class name with ".class" extension in the end.

Parameters:
classType - class type
Returns:
class name with ".class" extension in the end

getClassName

public static java.lang.String getClassName(java.lang.Object classObject)
Returns class name.

Parameters:
classObject - object of class type
Returns:
class name

getClassName

public static java.lang.String getClassName(java.lang.Class classType)
Returns class name.

Parameters:
classType - class type
Returns:
class name

getClassPackages

public static java.lang.String[] getClassPackages(java.lang.Object classObject)
Returns class packages.

Parameters:
classObject - object of class type
Returns:
class packages

getClassPackages

public static java.lang.String[] getClassPackages(java.lang.Class classType)
Returns class packages.

Parameters:
classType - class type
Returns:
class packages

getPackages

public static java.lang.String[] getPackages(java.lang.String packageName)
Returns packages names.

Parameters:
packageName - package name
Returns:
packages names

getStaticFieldValueSafely

public static <T> T getStaticFieldValueSafely(java.lang.Class classType,
                                              java.lang.String fieldName)
Returns static field value from the specified class.

Parameters:
classType - class type
fieldName - class field name
Returns:
static field value from the specified class

getStaticFieldValue

public static <T> T getStaticFieldValue(java.lang.Class classType,
                                        java.lang.String fieldName)
                             throws java.lang.NoSuchFieldException,
                                    java.lang.IllegalAccessException
Returns static field value from the specified class.

Parameters:
classType - class type
fieldName - class field name
Returns:
static field value from the specified class
Throws:
java.lang.NoSuchFieldException
java.lang.IllegalAccessException

getInnerClass

public static java.lang.Class getInnerClass(java.lang.Class fromClass,
                                            java.lang.String innerClassName)
Returns inner class with the specified name.

Parameters:
fromClass - class to look for the inner class
innerClassName - inner class name
Returns:
inner class with the specified name

createInstanceSafely

public static <T> T createInstanceSafely(java.lang.String canonicalClassName,
                                         java.lang.Object... arguments)
Returns newly created class instance.

Parameters:
canonicalClassName - canonical class name
arguments - class constructor arguments
Returns:
newly created class instance

createInstance

public static <T> T createInstance(java.lang.String canonicalClassName,
                                   java.lang.Object... arguments)
                        throws java.lang.ClassNotFoundException,
                               java.lang.reflect.InvocationTargetException,
                               java.lang.IllegalAccessException,
                               java.lang.InstantiationException,
                               java.lang.NoSuchMethodException
Returns newly created class instance.

Parameters:
canonicalClassName - canonical class name
arguments - class constructor arguments
Returns:
newly created class instance
Throws:
java.lang.ClassNotFoundException
java.lang.reflect.InvocationTargetException
java.lang.IllegalAccessException
java.lang.InstantiationException
java.lang.NoSuchMethodException

createInstanceSafely

public static <T> T createInstanceSafely(java.lang.Class theClass,
                                         java.lang.Object... arguments)
Returns newly created class instance.

Parameters:
theClass - class to process
arguments - class constructor arguments
Returns:
newly created class instance

createInstance

public static <T> T createInstance(java.lang.Class theClass,
                                   java.lang.Object... arguments)
                        throws java.lang.InstantiationException,
                               java.lang.IllegalAccessException,
                               java.lang.reflect.InvocationTargetException,
                               java.lang.NoSuchMethodException
Returns newly created class instance.

Parameters:
theClass - class to process
arguments - class constructor arguments
Returns:
newly created class instance
Throws:
java.lang.InstantiationException
java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
java.lang.NoSuchMethodException

getConstructor

public static java.lang.reflect.Constructor getConstructor(java.lang.Class theClass,
                                                           java.lang.Class... parameterTypes)
                                                    throws java.lang.NoSuchMethodException
Returns class constructor for the specified argument types.

Parameters:
theClass - class to process
parameterTypes - constructor argument types
Returns:
class constructor for the specified argument types
Throws:
java.lang.NoSuchMethodException

callStaticMethodSafely

public static <T> T callStaticMethodSafely(java.lang.String canonicalClassName,
                                           java.lang.String methodName,
                                           java.lang.Object... arguments)
Returns result of called static method. Will return null in case method is void-type.

Parameters:
canonicalClassName - canonical class name
methodName - static method name
arguments - method arguments
Returns:
result of called static method

callStaticMethod

public static <T> T callStaticMethod(java.lang.String canonicalClassName,
                                     java.lang.String methodName,
                                     java.lang.Object... arguments)
                          throws java.lang.ClassNotFoundException,
                                 java.lang.reflect.InvocationTargetException,
                                 java.lang.NoSuchMethodException,
                                 java.lang.IllegalAccessException
Returns result of called static method. Will return null in case method is void-type.

Parameters:
canonicalClassName - canonical class name
methodName - static method name
arguments - method arguments
Returns:
result of called static method
Throws:
java.lang.ClassNotFoundException
java.lang.reflect.InvocationTargetException
java.lang.NoSuchMethodException
java.lang.IllegalAccessException

callStaticMethodSafely

public static <T> T callStaticMethodSafely(java.lang.Class theClass,
                                           java.lang.String methodName,
                                           java.lang.Object... arguments)
Returns result of called static method. Will return null in case method is void-type.

Parameters:
theClass - class to process
methodName - static method name
arguments - method arguments
Returns:
result of called static method

callStaticMethod

public static <T> T callStaticMethod(java.lang.Class theClass,
                                     java.lang.String methodName,
                                     java.lang.Object... arguments)
                          throws java.lang.NoSuchMethodException,
                                 java.lang.reflect.InvocationTargetException,
                                 java.lang.IllegalAccessException
Returns result of called static method. Will return null in case method is void-type.

Parameters:
theClass - class to process
methodName - static method name
arguments - static method arguments
Returns:
result given by called static method
Throws:
java.lang.NoSuchMethodException
java.lang.reflect.InvocationTargetException
java.lang.IllegalAccessException

callMethodsSafely

public static <T> java.util.List<T> callMethodsSafely(java.util.List objects,
                                                      java.lang.String methodName,
                                                      java.lang.Object... arguments)
Returns list of results returned by called methods.

Parameters:
objects - objects to call methods on
methodName - method name
arguments - method arguments
Returns:
list of results returned by called methods

callMethods

public static <T> java.util.List<T> callMethods(java.util.List objects,
                                                java.lang.String methodName,
                                                java.lang.Object... arguments)
                                     throws java.lang.NoSuchMethodException,
                                            java.lang.reflect.InvocationTargetException,
                                            java.lang.IllegalAccessException
Returns list of results returned by called methods.

Parameters:
objects - objects to call methods on
methodName - method name
arguments - method arguments
Returns:
list of results returned by called methods
Throws:
java.lang.NoSuchMethodException
java.lang.reflect.InvocationTargetException
java.lang.IllegalAccessException

callMethodsSafely

public static java.lang.Object[] callMethodsSafely(java.lang.Object[] objects,
                                                   java.lang.String methodName,
                                                   java.lang.Object... arguments)
Returns an array of results returned by called methods.

Parameters:
objects - objects to call methods on
methodName - method name
arguments - method arguments
Returns:
an array of results returned by called methods

callMethods

public static java.lang.Object[] callMethods(java.lang.Object[] objects,
                                             java.lang.String methodName,
                                             java.lang.Object... arguments)
                                      throws java.lang.NoSuchMethodException,
                                             java.lang.reflect.InvocationTargetException,
                                             java.lang.IllegalAccessException
Returns an array of results returned by called methods.

Parameters:
objects - objects to call methods on
methodName - method name
arguments - method arguments
Returns:
an array of results returned by called methods
Throws:
java.lang.NoSuchMethodException
java.lang.reflect.InvocationTargetException
java.lang.IllegalAccessException

callMethodSafely

public static <T> T callMethodSafely(java.lang.Object object,
                                     java.lang.String methodName,
                                     java.lang.Object... arguments)
Returns result given by called method.

Parameters:
object - object instance
methodName - method name
arguments - method arguments
Returns:
result given by called method

callMethod

public static <T> T callMethod(java.lang.Object object,
                               java.lang.String methodName,
                               java.lang.Object... arguments)
                    throws java.lang.NoSuchMethodException,
                           java.lang.reflect.InvocationTargetException,
                           java.lang.IllegalAccessException
Calls object's method with the specified name and arguments. If method is not found in the object class all superclasses will be searched for that method. Returns result given by called method.

Parameters:
object - object instance
methodName - method name
arguments - method arguments
Returns:
result given by called method
Throws:
java.lang.NoSuchMethodException
java.lang.reflect.InvocationTargetException
java.lang.IllegalAccessException

getFieldGetter

public static java.lang.reflect.Method getFieldGetter(java.lang.Object object,
                                                      java.lang.String field)
Returns field getter methor by popular method naming pattern. Basically those are "getFieldName"-like and "isFieldName"-like method names.

Parameters:
object - object
field - field name
Returns:
field getter methor by popular method naming pattern

getFieldGetter

public static java.lang.reflect.Method getFieldGetter(java.lang.Class aClass,
                                                      java.lang.String field)
Returns field getter methor by popular method naming pattern. Basically those are "getFieldName"-like and "isFieldName"-like method names.

Parameters:
aClass - object class
field - field name
Returns:
field getter methor by popular method naming pattern

getSetterMethodName

public static java.lang.String getSetterMethodName(java.lang.String field)
Returns setter method name for the specified field.

Parameters:
field - field name
Returns:
setter method name for the specified field

getGetterMethodName

public static java.lang.String getGetterMethodName(java.lang.String field)
Returns getter method name for the specified field.

Parameters:
field - field name
Returns:
getter method name for the specified field

getIsGetterMethodName

public static java.lang.String getIsGetterMethodName(java.lang.String field)
Returns "is" getter method name for the specified field.

Parameters:
field - field name
Returns:
"is" getter method name for the specified field

getMethodSafely

public static java.lang.reflect.Method getMethodSafely(java.lang.Object object,
                                                       java.lang.String methodName,
                                                       java.lang.Object... arguments)
Calls object's method with the specified name and arguments. If method is not found in the object class all superclasses will be searched for that method. Returns result given by called method.

Parameters:
object - object
methodName - method name
arguments - method arguments
Returns:
result given by called method

getMethodSafely

public static java.lang.reflect.Method getMethodSafely(java.lang.Class aClass,
                                                       java.lang.String methodName,
                                                       java.lang.Object... arguments)
Returns object's method with the specified name and arguments. If method is not found in the object class all superclasses will be searched for that method.

Parameters:
aClass - object class
methodName - method name
arguments - method arguments
Returns:
object's method with the specified name and arguments

getMethod

public static java.lang.reflect.Method getMethod(java.lang.Object object,
                                                 java.lang.String methodName,
                                                 java.lang.Object... arguments)
                                          throws java.lang.NoSuchMethodException,
                                                 java.lang.reflect.InvocationTargetException,
                                                 java.lang.IllegalAccessException
Returns object's method with the specified name and arguments. If method is not found in the object class all superclasses will be searched for that method.

Parameters:
object - object
methodName - method name
arguments - method arguments
Returns:
object's method with the specified name and arguments
Throws:
java.lang.NoSuchMethodException
java.lang.reflect.InvocationTargetException
java.lang.IllegalAccessException

getMethod

public static java.lang.reflect.Method getMethod(java.lang.Class aClass,
                                                 java.lang.String methodName,
                                                 java.lang.Object... arguments)
                                          throws java.lang.NoSuchMethodException,
                                                 java.lang.reflect.InvocationTargetException,
                                                 java.lang.IllegalAccessException
Returns object's method with the specified name and arguments. If method is not found in the object class all superclasses will be searched for that method.

Parameters:
aClass - object class
methodName - method name
arguments - method arguments
Returns:
object's method with the specified name and arguments
Throws:
java.lang.NoSuchMethodException
java.lang.reflect.InvocationTargetException
java.lang.IllegalAccessException

getMethodImpl

protected static java.lang.reflect.Method getMethodImpl(java.lang.Class aClass,
                                                        java.lang.String methodName,
                                                        java.lang.Object[] arguments)
                                                 throws java.lang.NoSuchMethodException,
                                                        java.lang.IllegalAccessException,
                                                        java.lang.reflect.InvocationTargetException
Returns object's method with the specified name and arguments. If method is not found in the object class all superclasses will be searched for that method.

Parameters:
aClass - object class
methodName - method name
arguments - method arguments
Returns:
object's method with the specified name and arguments
Throws:
java.lang.NoSuchMethodException
java.lang.reflect.InvocationTargetException
java.lang.IllegalAccessException

clone

public static <T extends java.lang.Cloneable> T clone(T object)
                                           throws java.lang.NoSuchMethodException,
                                                  java.lang.IllegalAccessException,
                                                  java.lang.reflect.InvocationTargetException
Returns cloned object.

Type Parameters:
T - cloned object type
Parameters:
object - object to clone
Returns:
cloned object
Throws:
java.lang.NoSuchMethodException
java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException

cloneSafely

public static <T extends java.lang.Cloneable> T cloneSafely(T object)
Returns cloned object.

Type Parameters:
T - cloned object type
Parameters:
object - object to clone
Returns:
cloned object

loadClass

public static java.lang.Class loadClass(java.lang.String canonicalClassName)
                                 throws java.lang.ClassNotFoundException
Returns class loaded for the specified canonical class name.

Parameters:
canonicalClassName - canonical class name
Returns:
class loaded for the specified canonical class name
Throws:
java.lang.ClassNotFoundException

getClassTypes

public static java.lang.Class[] getClassTypes(java.lang.Object[] arguments)
Returns an array of argument class types.

Parameters:
arguments - arguments to process
Returns:
an array of argument class types

isAssignable

public static boolean isAssignable(java.lang.Class type,
                                   java.lang.Class from)
Returns whether first type is assignable from second one or not.

Parameters:
type - checked whether is assignable, always not null
from - checked type, might be null
Returns:
true if first type is assignable from second one, false otherwise

containsInClassOrSuperclassName

public static boolean containsInClassOrSuperclassName(java.lang.Class theClass,
                                                      java.lang.String text)
Returns whether one of superclasses contains specified text in its name or not.

Parameters:
theClass - class to process
text - text to search for
Returns:
true if one of superclasses contains specified text in its name, false otherwise