|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.lucene.gdata.utils.ReflectionUtils
public class ReflectionUtils
A collection of static helper methods solve common reflection problems
Nested Class Summary | |
---|---|
static class |
ReflectionUtils.ReflectionException
Exception wrapper for all thrown exception in the ReflectionUtils methods |
Constructor Summary | |
---|---|
ReflectionUtils()
|
Method Summary | ||
---|---|---|
static boolean |
canCreateInstance(Class clazz)
This method calls Class.newInstance() to get a new instance. |
|
static boolean |
extendsType(Class typeToCheck,
Class superType)
Check if the given type extends a given super type |
|
static
|
getDefaultInstance(Class<T> clazz)
|
|
static Class |
getPrimitiveWrapper(Class primitive)
Returns the wrapper type for the given primitive type. |
|
static boolean |
hasDesiredConstructor(Class type,
Class[] parameter)
|
|
static boolean |
implementsType(Class typeToCheck,
Class superType)
Check if the given type implements a given super type |
|
static boolean |
isTypeOf(Class typeToCheck,
Class superType)
This method combines the extendsType and implementsType and checks interfaces and classes |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ReflectionUtils()
Method Detail |
---|
public static boolean implementsType(Class typeToCheck, Class superType)
typeToCheck
- - type supposed to implement an interfacesuperType
- - the interface to be implemented by the type to check
true
if and only if the super type is above in the type hierarchy of the given type, otherwise false
public static boolean extendsType(Class typeToCheck, Class superType)
typeToCheck
- - type supposed to extend an specific typesuperType
- - the type to be extended by the type to check
true
if and only if the super type is above in the type hierarchy of the given type, otherwise false
public static boolean isTypeOf(Class typeToCheck, Class superType)
typeToCheck
- - type supposed to extend / implement an specific typesuperType
- - the type to be extended / implemented by the type to check
true
if and only if the super type is above in the type hierarchy of the given type, otherwise false
public static boolean hasDesiredConstructor(Class type, Class[] parameter)
type
- - the type to checkparameter
- - the constructor parameter
true
if and only if the type has a visible constructor with the desired parameterspublic static <T> T getDefaultInstance(Class<T> clazz)
T
- the type of the class to instantiateclazz
- - class object of the type
public static boolean canCreateInstance(Class clazz)
Class.newInstance()
to get a new instance. Use with care!
clazz
- - the class to instantiate
true
if an instance could be created, otherwise false;public static final Class getPrimitiveWrapper(Class primitive)
primitive
- - the primitive type
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |