public final class ClassUtil
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
ClassUtil.TypeInfo |
Constructor and Description |
---|
ClassUtil() |
Modifier and Type | Method and Description |
---|---|
static void |
extractInterfaces(java.util.Set<java.lang.Class<?>> iSet,
java.lang.Class<?> clazz) |
static java.lang.reflect.Type |
getActualValueOfTypevariable(java.lang.Class<?> clazz,
java.lang.reflect.TypeVariable<?> typevariable)
Finds an actual value of a type variable.
|
static java.lang.reflect.Field[] |
getAllFields(java.lang.Class<?> clazz,
java.lang.Class<?> uptoParent)
Get all fields of the class including parent up to given level in hierarchy.
|
static java.util.Set<java.lang.reflect.Method> |
getAllMethodsWithAnnotation(java.lang.Class<?> cls,
java.lang.Class<? extends java.lang.annotation.Annotation> annotation) |
static java.util.Set<java.lang.reflect.Method> |
getAllMethodsWithAnnotation(java.lang.String packageName,
java.lang.Class<? extends java.lang.annotation.Annotation> annotation) |
static <T extends java.lang.annotation.Annotation> |
getAnnotation(java.lang.Class<?> clazz,
java.lang.Class<T> annotation) |
static <T extends java.lang.annotation.Annotation> |
getAnnotation(java.lang.reflect.Method method,
java.lang.Class<T> annotation) |
static java.lang.Class<?> |
getClass(java.lang.reflect.Type typeOfT) |
static java.util.List<java.lang.Class<?>> |
getClasses(java.lang.String pkg) |
static java.lang.Class |
getCollectionBaseType(java.lang.Class type,
java.lang.reflect.Type genericType) |
static java.lang.reflect.Field |
getField(java.lang.String fieldName,
java.lang.Class<?> clazz) |
static java.lang.Object |
getField(java.lang.String fieldName,
java.lang.Object classObj) |
static java.lang.reflect.Type[] |
getGenericParameterTypesOfGenericInterfaceMethod(java.lang.Class clazz,
java.lang.reflect.Method method)
Given an interface Method, look in the implementing class for the method that
implements the interface's method to obtain generic type information.
|
static java.lang.reflect.Type |
getGenericReturnTypeOfGenericInterfaceMethod(java.lang.Class clazz,
java.lang.reflect.Method method)
Given an interface Method, look in the implementing class for the method that
implements the interface's method to obtain generic type information.
|
static <C> C |
getInstance()
Get instance of Parameterized class by calling default constructor.
|
static java.lang.Class |
getMapKeyType(java.lang.reflect.Type genericType) |
static java.lang.Class |
getMapValueType(java.lang.reflect.Type genericType) |
static java.lang.reflect.Method |
getMethod(java.lang.Class<?> clazz,
java.lang.String name)
Get all methods of the class including parent.
|
static java.lang.String |
getMethodSignture(java.lang.reflect.Method m,
boolean includeClass) |
static java.lang.Class<?> |
getRawType(java.lang.reflect.Type type) |
static java.lang.Class<?> |
getRawTypeNoException(java.lang.reflect.Type type) |
static java.lang.Class |
getTemplateParameterOfInterface(java.lang.Class base,
java.lang.Class desiredInterface) |
static java.lang.Class<?> |
getTypeArgument(java.lang.reflect.Type genericType)
Returns the type argument from a parameterized type
|
static boolean |
hasAnnotation(java.lang.reflect.Method method,
java.lang.Class<? extends java.lang.annotation.Annotation> annotation) |
static boolean |
isAssignableFrom(java.lang.reflect.Type typeOfT,
java.lang.Class<?> clazz) |
static boolean |
isPrimitiveOrWrapperType(java.lang.Class<?> clazz) |
static boolean |
isWrapperType(java.lang.Class<?> clazz) |
static void |
setField(java.lang.String fieldName,
java.lang.Object classObj,
java.lang.Object value) |
public static java.util.Set<java.lang.reflect.Method> getAllMethodsWithAnnotation(java.lang.String packageName, java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
public static java.util.Set<java.lang.reflect.Method> getAllMethodsWithAnnotation(java.lang.Class<?> cls, java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
public static boolean hasAnnotation(java.lang.reflect.Method method, java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
public static <T extends java.lang.annotation.Annotation> T getAnnotation(java.lang.reflect.Method method, java.lang.Class<T> annotation)
public static <T extends java.lang.annotation.Annotation> T getAnnotation(java.lang.Class<?> clazz, java.lang.Class<T> annotation)
public static java.util.List<java.lang.Class<?>> getClasses(java.lang.String pkg) throws java.io.IOException
java.io.IOException
public static java.lang.reflect.Method getMethod(java.lang.Class<?> clazz, java.lang.String name) throws java.lang.NoSuchMethodException
clazz
- name
- case-insensitive method name to getjava.lang.NoSuchMethodException
public static java.lang.reflect.Field[] getAllFields(java.lang.Class<?> clazz, java.lang.Class<?> uptoParent)
clazz
- uptoParent
- - restrict hierarchy - to exclude fields from provided class and
it's parent(s) in hierarchypublic static void extractInterfaces(java.util.Set<java.lang.Class<?>> iSet, java.lang.Class<?> clazz)
public static <C> C getInstance()
C
- public static java.lang.String getMethodSignture(java.lang.reflect.Method m, boolean includeClass)
public static java.lang.Class getTemplateParameterOfInterface(java.lang.Class base, java.lang.Class desiredInterface)
public static java.lang.reflect.Type getGenericReturnTypeOfGenericInterfaceMethod(java.lang.Class clazz, java.lang.reflect.Method method)
interface Foo<T> { @GET List<T> get(); }
clazz
- method
- interface methodpublic static java.lang.reflect.Type[] getGenericParameterTypesOfGenericInterfaceMethod(java.lang.Class clazz, java.lang.reflect.Method method)
interface Foo<T> { @GET List<T> get(); }
clazz
- method
- interface methodpublic static java.lang.Class<?> getRawType(java.lang.reflect.Type type)
public static java.lang.Class<?> getRawTypeNoException(java.lang.reflect.Type type)
public static java.lang.Class<?> getTypeArgument(java.lang.reflect.Type genericType)
genericType
- public static java.lang.Class getCollectionBaseType(java.lang.Class type, java.lang.reflect.Type genericType)
public static java.lang.Class getMapKeyType(java.lang.reflect.Type genericType)
public static java.lang.Class getMapValueType(java.lang.reflect.Type genericType)
public static java.lang.reflect.Type getActualValueOfTypevariable(java.lang.Class<?> clazz, java.lang.reflect.TypeVariable<?> typevariable)
clazz
- typevariable
- public static void setField(java.lang.String fieldName, java.lang.Object classObj, java.lang.Object value)
public static java.lang.reflect.Field getField(java.lang.String fieldName, java.lang.Class<?> clazz) throws java.lang.NoSuchFieldException
java.lang.NoSuchFieldException
public static java.lang.Object getField(java.lang.String fieldName, java.lang.Object classObj)
public static boolean isWrapperType(java.lang.Class<?> clazz)
clazz
- public static boolean isPrimitiveOrWrapperType(java.lang.Class<?> clazz)
public static boolean isAssignableFrom(java.lang.reflect.Type typeOfT, java.lang.Class<?> clazz)
public static java.lang.Class<?> getClass(java.lang.reflect.Type typeOfT)
Copyright © 2000 Infostretch Corp.