public final class TypeUtil extends Object
Constructor and Description |
---|
TypeUtil() |
Modifier and Type | Method and Description |
---|---|
static Type |
expandType(Type type,
Type rootType)
Expands type in the type rootType to Class, ParameterizedType or GenericArrayType.
|
static Type |
getCollectionType(Type type)
Returns the type of this Collection or Array.
|
static Class<?> |
getRawClass(Type type) |
static Type |
lookupGenericType(Class<?> ofClass,
Class<?> inClass)
Searches for ofClass in the inherited classes and interfaces of inClass.
|
static boolean |
match(Type type,
Type oType,
boolean strictMatch)
Deep comparison between type and oType.
|
static Type |
resolveTypeVariable(TypeVariable<? extends GenericDeclaration> type,
Class<?> inClass)
Searches for the typevariable definition in the inClass hierarchy.
|
static Type |
typeOf(int parameterIdx,
Type fromType)
Convenient method that returns the type of the parameter at position parameterIdx in the type fromType.
|
static Class<?> |
wrap(Class<?> clazz) |
public static final Type expandType(Type type, Type rootType)
public static final Type lookupGenericType(Class<?> ofClass, Class<?> inClass)
abstract class MyClass implements Serializer<Number> { } // type value will be the parameterized type Serializer<Number> Type type = lookupGenericType(Serializer.class, MyClass.class);
public static final Type getCollectionType(Type type)
IllegalArgumentException
- if type is not a Collection, not a generic array and not a primitive array.public static final Type resolveTypeVariable(TypeVariable<? extends GenericDeclaration> type, Class<?> inClass)
type
- inClass
- public static final boolean match(Type type, Type oType, boolean strictMatch)
public static final Type typeOf(int parameterIdx, Type fromType)
UnsupportedOperationException
- thrown if fromType is not a Class nor a ParameterizedType.Copyright © 2019. All rights reserved.