Package com.gengoai.reflection
Class TypeUtils
- java.lang.Object
-
- com.gengoai.reflection.TypeUtils
-
public final class TypeUtils extends Object
Convenience methods for creating type information
- Author:
- David B. Bracewell
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
TypeUtils.ParameterizedTypeImpl
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> Class<T>
asClass(Type type)
Converts type information to class informationstatic Type[]
getActualTypeArguments(Type type)
Get actual type arguments type [ ].static Type
getOrObject(int n, Type... types)
Gets or object.static boolean
isArray(Type type)
Is array boolean.static boolean
isAssignable(Type parent, Type child)
Is assignable boolean.static boolean
isCollection(Type type)
Is collection boolean.static boolean
isContainer(Type type)
Is container boolean.static boolean
isIterable(Type type)
Is iterable boolean.static boolean
isIterator(Type type)
Is iterator boolean.static boolean
isPrimitive(Type type)
Is primitive boolean.static Type
parameterizedType(Type rawType, Type... typeArguments)
Creates parameterized type information for the given raw type and optional type arguments.static Type
parse(String s)
From string type.
-
-
-
Method Detail
-
asClass
public static <T> Class<T> asClass(Type type)
Converts type information to class information- Type Parameters:
T
- the type parameter- Parameters:
type
- the type- Returns:
- the class
-
getActualTypeArguments
public static Type[] getActualTypeArguments(Type type)
Get actual type arguments type [ ].- Parameters:
type
- the type- Returns:
- the type [ ]
-
getOrObject
public static Type getOrObject(int n, Type... types)
Gets or object.- Parameters:
n
- the ntypes
- the types- Returns:
- the or object
-
isArray
public static boolean isArray(Type type)
Is array boolean.- Parameters:
type
- the type- Returns:
- the boolean
-
isAssignable
public static boolean isAssignable(Type parent, Type child)
Is assignable boolean.- Parameters:
parent
- the t 1child
- the to check- Returns:
- the boolean
-
isCollection
public static boolean isCollection(Type type)
Is collection boolean.- Parameters:
type
- the type- Returns:
- the boolean
-
isContainer
public static boolean isContainer(Type type)
Is container boolean.- Parameters:
type
- the type- Returns:
- the boolean
-
isIterable
public static boolean isIterable(Type type)
Is iterable boolean.- Parameters:
type
- the type- Returns:
- the boolean
-
isIterator
public static boolean isIterator(Type type)
Is iterator boolean.- Parameters:
type
- the type- Returns:
- the boolean
-
isPrimitive
public static boolean isPrimitive(Type type)
Is primitive boolean.- Parameters:
type
- the type- Returns:
- the boolean
-
parameterizedType
public static Type parameterizedType(Type rawType, Type... typeArguments)
Creates parameterized type information for the given raw type and optional type arguments.- Parameters:
rawType
- the raw typetypeArguments
- the type arguments- Returns:
- the parameterized type
-
-