org.qi4j.api.util
Class Classes

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

public final class Classes
extends java.lang.Object

Useful methods for handling Classes.


Field Summary
static Function<java.lang.reflect.Type,java.lang.Class<?>> RAW_CLASS
          Function that extract the raw class of a type.
 
Constructor Summary
Classes()
           
 
Method Summary
static Specification<ModelDescriptor> assignableTypeSpecification(java.lang.Class type)
           
static java.lang.Iterable<java.lang.Class<?>> classHierarchy(java.lang.Class<?> type)
           
static java.lang.String denormalizeURIToClass(java.lang.String uriPart)
           
static Specification<ModelDescriptor> exactTypeSpecification(java.lang.Class type)
           
static
<AnnotationType extends java.lang.annotation.Annotation>
AnnotationType
findAnnotationOfTypeOrAnyOfSuperTypes(java.lang.Class<?> type, java.lang.Class<AnnotationType> annotationClass)
           
static
<T> Function<java.lang.reflect.Type,java.lang.Iterable<T>>
forClassHierarchy(Function<java.lang.Class<?>,java.lang.Iterable<T>> function)
           
static
<T> Function<java.lang.reflect.Type,java.lang.Iterable<T>>
forTypes(Function<java.lang.reflect.Type,java.lang.Iterable<T>> function)
           
static Specification<java.lang.Class<?>> hasModifier(int classModifier)
           
static Specification<java.lang.Object> instanceOf(java.lang.Class clazz)
           
static java.lang.Iterable<? extends java.lang.reflect.Type> interfacesOf(java.lang.Iterable<? extends java.lang.reflect.Type> types)
           
static java.lang.Iterable<java.lang.reflect.Type> interfacesOf(java.lang.reflect.Type type)
           
static java.util.Set<java.lang.Class<?>> interfacesWithMethods(java.util.Set<java.lang.Class<?>> interfaces)
           
static Specification<java.lang.Class<?>> isAssignableFrom(java.lang.Class clazz)
           
static Specification<java.lang.reflect.Member> memberNamed(java.lang.String name)
           
static Specification<ModelDescriptor> modelTypeSpecification(java.lang.String className)
           
static java.lang.String normalizeClassToURI(java.lang.String className)
           
static java.lang.reflect.Type resolveTypeVariable(java.lang.reflect.TypeVariable name, java.lang.Class declaringClass, java.lang.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 java.lang.String simpleGenericNameOf(java.lang.reflect.Type type)
           
static Function<java.lang.reflect.Type,java.lang.String> toClassName()
           
static java.lang.String toClassName(java.lang.String uri)
          Get class name from a URI
static java.lang.String toString(java.lang.Iterable<? extends java.lang.Class> type)
           
static java.lang.String toURI(java.lang.Class clazz)
          Get URI for a class.
static java.lang.String toURI(java.lang.String className)
          Get URI for a class name.
static java.lang.reflect.Type typeOf(java.lang.reflect.AccessibleObject from)
           
static java.lang.Iterable<java.lang.reflect.Type> typesOf(java.lang.Iterable<java.lang.reflect.Type> types)
           
static java.lang.Iterable<java.lang.reflect.Type> typesOf(java.lang.reflect.Type type)
           
static java.lang.reflect.Type wrapperClass(java.lang.reflect.Type type)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RAW_CLASS

public static final Function<java.lang.reflect.Type,java.lang.Class<?>> RAW_CLASS
Function that extract the raw class of a type.

Constructor Detail

Classes

public Classes()
Method Detail

typeOf

public static java.lang.reflect.Type typeOf(java.lang.reflect.AccessibleObject from)

typesOf

public static java.lang.Iterable<java.lang.reflect.Type> typesOf(java.lang.Iterable<java.lang.reflect.Type> types)

typesOf

public static java.lang.Iterable<java.lang.reflect.Type> typesOf(java.lang.reflect.Type type)

interfacesOf

public static java.lang.Iterable<? extends java.lang.reflect.Type> interfacesOf(java.lang.Iterable<? extends java.lang.reflect.Type> types)

interfacesOf

public static java.lang.Iterable<java.lang.reflect.Type> interfacesOf(java.lang.reflect.Type type)

classHierarchy

public static java.lang.Iterable<java.lang.Class<?>> classHierarchy(java.lang.Class<?> type)

wrapperClass

public static java.lang.reflect.Type wrapperClass(java.lang.reflect.Type type)

isAssignableFrom

public static Specification<java.lang.Class<?>> isAssignableFrom(java.lang.Class clazz)

instanceOf

public static Specification<java.lang.Object> instanceOf(java.lang.Class clazz)

hasModifier

public static Specification<java.lang.Class<?>> hasModifier(int classModifier)

forClassHierarchy

public static <T> Function<java.lang.reflect.Type,java.lang.Iterable<T>> forClassHierarchy(Function<java.lang.Class<?>,java.lang.Iterable<T>> function)

forTypes

public static <T> Function<java.lang.reflect.Type,java.lang.Iterable<T>> forTypes(Function<java.lang.reflect.Type,java.lang.Iterable<T>> function)

interfacesWithMethods

public static java.util.Set<java.lang.Class<?>> interfacesWithMethods(java.util.Set<java.lang.Class<?>> interfaces)

simpleGenericNameOf

public static java.lang.String simpleGenericNameOf(java.lang.reflect.Type type)

findAnnotationOfTypeOrAnyOfSuperTypes

public static <AnnotationType extends java.lang.annotation.Annotation> AnnotationType findAnnotationOfTypeOrAnyOfSuperTypes(java.lang.Class<?> type,
                                                                                                                            java.lang.Class<AnnotationType> annotationClass)

memberNamed

public static Specification<java.lang.reflect.Member> memberNamed(java.lang.String name)

resolveTypeVariable

public static java.lang.reflect.Type resolveTypeVariable(java.lang.reflect.TypeVariable name,
                                                         java.lang.Class declaringClass,
                                                         java.lang.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 java.lang.String toURI(java.lang.Class clazz)
                              throws java.lang.NullPointerException
Get URI for a class.

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

toURI

public static java.lang.String toURI(java.lang.String className)
                              throws java.lang.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:
java.lang.NullPointerException - if className is null

toClassName

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

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

normalizeClassToURI

public static java.lang.String normalizeClassToURI(java.lang.String className)

denormalizeURIToClass

public static java.lang.String denormalizeURIToClass(java.lang.String uriPart)

modelTypeSpecification

public static Specification<ModelDescriptor> modelTypeSpecification(java.lang.String className)

exactTypeSpecification

public static Specification<ModelDescriptor> exactTypeSpecification(java.lang.Class type)

assignableTypeSpecification

public static Specification<ModelDescriptor> assignableTypeSpecification(java.lang.Class type)

toString

public static java.lang.String toString(java.lang.Iterable<? extends java.lang.Class> type)

toClassName

public static Function<java.lang.reflect.Type,java.lang.String> toClassName()