org.qi4j.api.util
Class Classes

java.lang.Object
  extended by org.qi4j.api.util.Classes

public final class Classes
extends Object

Class-related utility methods


Constructor Summary
Classes()
           
 
Method Summary
static Type actualTypeOf(Type type)
           
static Set<Class> classesOf(Type type)
           
static List<Constructor> constructorsOf(Class clazz)
           
static String denormalizeURIToClass(String uriPart)
           
static List<Field> fieldsOf(Class clazz)
           
static Set<Type> genericInterfacesOf(Type type)
          Get all interfaces for the given type, including the provided type.
static
<AnnotationType extends Annotation>
AnnotationType
getAnnotationOfTypeOrAnyOfSuperTypes(Class<?> type, Class<AnnotationType> annotationClass)
           
static Class<?> getRawClass(Type genericType)
           
static String getSimpleGenericName(Type type)
           
static Set<Class> interfacesOf(Type type)
          Get all interfaces for the given type, including the provided type.
static Set<Class> interfacesWithMethods(Set<Class> interfaces)
           
static List<Method> methodsOf(Class clazz)
           
static String normalizeClassToURI(String className)
           
static Type resolveTypeVariable(TypeVariable name, Class declaringClass, Class topClass)
          Given a type variable, find what it resolves to given the declaring class where type variable was found and a top class that extends the declaring class.
static Class[] toClassArray(Set<Class> types)
           
static String toClassName(String uri)
          Get class name from a URI
static String toURI(Class clazz)
          Get URI for a class.
static String toURI(String className)
          Get URI for a class name.
static Set<Class> typesOf(Type type)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Classes

public Classes()
Method Detail

interfacesOf

public static Set<Class> interfacesOf(Type type)
Get all interfaces for the given type, including the provided type. No type is included twice in the list.

Parameters:
type - to extract interfaces from
Returns:
set of interfaces of given type

genericInterfacesOf

public static Set<Type> genericInterfacesOf(Type type)
Get all interfaces for the given type, including the provided type. No type is included twice in the list.

Parameters:
type - to extract interfaces from
Returns:
set of interfaces of given type

interfacesWithMethods

public static Set<Class> interfacesWithMethods(Set<Class> interfaces)

classesOf

public static Set<Class> classesOf(Type type)

typesOf

public static Set<Class> typesOf(Type type)

toClassArray

public static Class[] toClassArray(Set<Class> types)

actualTypeOf

public static Type actualTypeOf(Type type)

getSimpleGenericName

public static String getSimpleGenericName(Type type)

getAnnotationOfTypeOrAnyOfSuperTypes

public static <AnnotationType extends Annotation> AnnotationType getAnnotationOfTypeOrAnyOfSuperTypes(Class<?> type,
                                                                                                      Class<AnnotationType> annotationClass)

getRawClass

public static Class<?> getRawClass(Type genericType)

constructorsOf

public static List<Constructor> constructorsOf(Class clazz)

methodsOf

public static List<Method> methodsOf(Class clazz)

fieldsOf

public static List<Field> fieldsOf(Class clazz)

resolveTypeVariable

public static Type resolveTypeVariable(TypeVariable name,
                                       Class declaringClass,
                                       Class topClass)
Given a type variable, find what it resolves to given the declaring class where type variable was found and a top class that extends the declaring class.

Parameters:
name -
declaringClass -
topClass -
Returns:

toURI

public static String toURI(Class clazz)
                    throws NullPointerException
Get URI for a class.

Parameters:
clazz - class
Returns:
URI
Throws:
NullPointerException - if clazz is null

toURI

public static String toURI(String className)
                    throws NullPointerException
Get URI for a class name.

Example: Class name com.example.Foo$Bar is converted to URI urn:qi4j:com.example.Foo-Bar

Parameters:
className - class name
Returns:
URI
Throws:
NullPointerException - if className is null

toClassName

public static String toClassName(String uri)
                          throws NullPointerException
Get class name from a URI

Parameters:
uri - URI
Returns:
class name
Throws:
NullPointerException - if uri is null

normalizeClassToURI

public static String normalizeClassToURI(String className)

denormalizeURIToClass

public static String denormalizeURIToClass(String uriPart)