public final class Types extends Object
Modifier and Type | Class and Description |
---|---|
static class |
Types.TypeInfo |
Modifier and Type | Method and Description |
---|---|
static Type[] |
findClassParameterizedTypes(Class<?> root,
ParameterizedType rootType,
Class<?> searchedForClass) |
static Type[] |
findInterfaceParameterizedTypes(Class<?> root,
ParameterizedType rootType,
Class<?> searchedForInterface) |
static Type[] |
findParameterizedTypes(Class<?> root,
Class<?> searchedFor)
Search for the given interface or class within the root's class/interface hierarchy.
|
static Type[] |
getActualTypeArgumentsOfAnInterface(Class<?> classToSearch,
Class<?> interfaceToFind)
Given a class and an interfaces, go through the class hierarchy to find the interface and return its type arguments.
|
static Type |
getActualValueOfTypeVariable(Class<?> clazz,
TypeVariable<?> typeVariable)
Finds an actual value of a type variable.
|
static Class |
getArgumentType(ParameterizedType pType,
int index)
Gets the index-th type argument.
|
static Class |
getCollectionBaseType(Class type,
Type genericType) |
static <T> Type |
getGenericReturnTypeOfGenericInterfaceMethod(Class<T> clazz,
Method method)
Given an interface Method, look in the implementing class for the method that implements the interface's method
to obtain generic type information.
|
static <T> Method |
getImplementingMethod(Class<T> clazz,
Method intfMethod)
Given a method and a root class, find the actual method declared in the root that implements the method.
|
static Class |
getMapKeyType(Type genericType) |
static Class |
getMapValueType(Type genericType) |
static Class<?> |
getRawType(Type type) |
static Class<?> |
getRawTypeNoException(Type type) |
static Class |
getTemplateParameterOfInterface(Class base,
Class desiredInterface) |
static Class<?> |
getTypeArgument(Type genericType)
Returns the type argument from a parameterized type
|
static <T> boolean |
isA(Class<T> clazz,
ParameterizedType pType)
Is the genericType of a certain class?
|
static boolean |
isCompatible(Method method,
Method intfMethod)
See if the two methods are compatible, that is they have the same relative signature
|
public static <T> boolean isA(Class<T> clazz, ParameterizedType pType)
public static Class getArgumentType(ParameterizedType pType, int index)
public static Class getTemplateParameterOfInterface(Class base, Class desiredInterface)
public static <T> Type getGenericReturnTypeOfGenericInterfaceMethod(Class<T> clazz, Method method)
interface Foo<T> { @GET List<T> get(); }
method
- interface methodpublic static boolean isCompatible(Method method, Method intfMethod)
public static <T> Method getImplementingMethod(Class<T> clazz, Method intfMethod)
public static Class<?> getTypeArgument(Type genericType)
public static Type getActualValueOfTypeVariable(Class<?> clazz, TypeVariable<?> typeVariable)
public static Type[] getActualTypeArgumentsOfAnInterface(Class<?> classToSearch, Class<?> interfaceToFind)
public static Type[] findParameterizedTypes(Class<?> root, Class<?> searchedFor)
public static Type[] findClassParameterizedTypes(Class<?> root, ParameterizedType rootType, Class<?> searchedForClass)
public static Type[] findInterfaceParameterizedTypes(Class<?> root, ParameterizedType rootType, Class<?> searchedForInterface)
Copyright © 2016. All rights reserved.