org.granite.util
Class TypeUtil

java.lang.Object
  extended by org.granite.util.TypeUtil

public abstract class TypeUtil
extends Object

Author:
Franck WOLFF

Nested Class Summary
static class TypeUtil.DeclaredAnnotation<T extends Annotation>
           
 
Constructor Summary
TypeUtil()
           
 
Method Summary
static Class<?> classOfType(Type type)
           
static
<T> List<T>
emptyList(Class<T> type)
           
static
<T,U> Map<T,U>
emptyMap(Class<T> keyType, Class<U> valueType)
           
static
<T> Set<T>
emptySet(Class<T> type)
           
static URL findResource(Class<?> clazz)
           
static Class<?> forName(String type)
           
static
<T> Class<T>
forName(String type, Class<T> cast)
           
static
<T extends Annotation>
TypeUtil.DeclaredAnnotation<T>
getAnnotation(AnnotatedElement elmt, Class<T> annotationClass)
           
static Type getBoundType(TypeVariable<?> typeVariable)
           
static
<T extends Annotation>
TypeUtil.DeclaredAnnotation<T>
getClassAnnotation(Class<?> clazz, Class<T> annotationClass)
           
static ClassLoader getClassLoader(Class<?> clazz)
           
static
<T> Constructor<T>
getConstructor(Class<T> type, Class<?>[] paramTypes)
           
static Constructor<?> getConstructor(String type, Class<?>[] paramTypes)
           
static
<T extends Annotation>
TypeUtil.DeclaredAnnotation<T>
getConstructorAnnotation(Class<?> clazz, Class<T> annotationClass)
           
static ParameterizedType[] getDeclaringTypes(Class<?> type)
           
static Method getMethod(Class<?> clazz, String signature)
           
static
<T extends Annotation>
TypeUtil.DeclaredAnnotation<T>
getMethodAnnotation(Class<?> clazz, String name, Class<?>[] parameterTypes, Class<T> annotationClass)
           
static String getMethodSignature(Method method)
           
static String getPackageName(Class<?> clazz)
           
static PropertyDescriptor[] getProperties(Class<?> clazz)
           
static String getTypeSignature(Class<?> type)
           
static boolean isAnnotationPresent(AnnotatedElement elmt, Class<? extends Annotation> annotationClass)
           
static boolean isPrimitive(Type type)
           
static
<T> T
newInstance(Class<?> type, Class<T> cast)
           
static
<T> T
newInstance(Class<T> type, Class<?>[] argsClass, Object[] argsValues)
           
static Object newInstance(String type)
           
static Object newInstance(String type, Class<?>[] argsClass, Object[] argsValues)
           
static
<T> T
newInstance(String type, Class<T> cast)
           
static Type resolveTypeVariable(Type genericType, Class<?> declaringClass, ParameterizedType[] declaringTypes)
           
static String toResourceName(Class<?> clazz)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TypeUtil

public TypeUtil()
Method Detail

newInstance

public static Object newInstance(String type)
                          throws ClassNotFoundException,
                                 InstantiationException,
                                 IllegalAccessException
Throws:
ClassNotFoundException
InstantiationException
IllegalAccessException

newInstance

public static <T> T newInstance(String type,
                                Class<T> cast)
                     throws ClassNotFoundException,
                            InstantiationException,
                            IllegalAccessException
Throws:
ClassNotFoundException
InstantiationException
IllegalAccessException

newInstance

public static Object newInstance(String type,
                                 Class<?>[] argsClass,
                                 Object[] argsValues)
                          throws ClassNotFoundException,
                                 InstantiationException,
                                 IllegalAccessException
Throws:
ClassNotFoundException
InstantiationException
IllegalAccessException

newInstance

public static <T> T newInstance(Class<?> type,
                                Class<T> cast)
                     throws InstantiationException,
                            IllegalAccessException
Throws:
InstantiationException
IllegalAccessException

newInstance

public static <T> T newInstance(Class<T> type,
                                Class<?>[] argsClass,
                                Object[] argsValues)
                     throws InstantiationException,
                            IllegalAccessException
Throws:
InstantiationException
IllegalAccessException

forName

public static Class<?> forName(String type)
                        throws ClassNotFoundException
Throws:
ClassNotFoundException

forName

public static <T> Class<T> forName(String type,
                                   Class<T> cast)
                        throws ClassNotFoundException
Throws:
ClassNotFoundException

getConstructor

public static Constructor<?> getConstructor(String type,
                                            Class<?>[] paramTypes)
                                     throws ClassNotFoundException,
                                            NoSuchMethodException
Throws:
ClassNotFoundException
NoSuchMethodException

getConstructor

public static <T> Constructor<T> getConstructor(Class<T> type,
                                                Class<?>[] paramTypes)
                                     throws NoSuchMethodException
Throws:
NoSuchMethodException

emptyList

public static <T> List<T> emptyList(Class<T> type)

emptySet

public static <T> Set<T> emptySet(Class<T> type)

emptyMap

public static <T,U> Map<T,U> emptyMap(Class<T> keyType,
                                      Class<U> valueType)

isPrimitive

public static boolean isPrimitive(Type type)

classOfType

public static Class<?> classOfType(Type type)

getBoundType

public static Type getBoundType(TypeVariable<?> typeVariable)

getDeclaringTypes

public static ParameterizedType[] getDeclaringTypes(Class<?> type)

resolveTypeVariable

public static Type resolveTypeVariable(Type genericType,
                                       Class<?> declaringClass,
                                       ParameterizedType[] declaringTypes)

getPackageName

public static String getPackageName(Class<?> clazz)

getProperties

public static PropertyDescriptor[] getProperties(Class<?> clazz)

getClassLoader

public static ClassLoader getClassLoader(Class<?> clazz)

findResource

public static URL findResource(Class<?> clazz)

toResourceName

public static String toResourceName(Class<?> clazz)

getMethodSignature

public static String getMethodSignature(Method method)

getTypeSignature

public static String getTypeSignature(Class<?> type)

getMethod

public static Method getMethod(Class<?> clazz,
                               String signature)
                        throws NoSuchMethodException
Throws:
NoSuchMethodException

isAnnotationPresent

public static boolean isAnnotationPresent(AnnotatedElement elmt,
                                          Class<? extends Annotation> annotationClass)

getAnnotation

public static <T extends Annotation> TypeUtil.DeclaredAnnotation<T> getAnnotation(AnnotatedElement elmt,
                                                                                  Class<T> annotationClass)

getMethodAnnotation

public static <T extends Annotation> TypeUtil.DeclaredAnnotation<T> getMethodAnnotation(Class<?> clazz,
                                                                                        String name,
                                                                                        Class<?>[] parameterTypes,
                                                                                        Class<T> annotationClass)

getConstructorAnnotation

public static <T extends Annotation> TypeUtil.DeclaredAnnotation<T> getConstructorAnnotation(Class<?> clazz,
                                                                                             Class<T> annotationClass)

getClassAnnotation

public static <T extends Annotation> TypeUtil.DeclaredAnnotation<T> getClassAnnotation(Class<?> clazz,
                                                                                       Class<T> annotationClass)