public final class GenericsUtil extends Object
| Constructor and Description |
|---|
GenericsUtil() |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
containsTypeVariable(Type type) |
static boolean |
containsWildcardType(Type type) |
static boolean |
containTypeVariable(Collection<? extends Type> types) |
static boolean |
containTypeVariable(Type[] types) |
static Set<Type> |
getDirectTypeClosure(Type type,
Type actualType) |
static ParameterizedType |
getParameterizedType(Type type) |
static <T> Class<T> |
getRawType(Type type) |
static Set<Type> |
getTypeClosure(Class<?> type) |
static Set<Type> |
getTypeClosure(Type actualType) |
static Set<Type> |
getTypeClosure(Type type,
Type actualType)
Returns the type closure for the specified parameters.
|
static boolean |
hasTypeParameters(Type type) |
static boolean |
isAssignableFrom(boolean isDelegateOrEvent,
boolean isProducer,
Type requiredType,
Type beanType)
5.2.3 and 5.2.4
|
static Type[] |
resolveParameterTypes(Class<?> subclass,
Constructor<?> constructor)
Resolves the actual parameter types of the specified constructor for the type hierarchy specified by the given subclass
|
static Type[] |
resolveParameterTypes(Class<?> subclass,
Method method)
Resolves the actual parameter types of the specified method for the type hierarchy specified by the given subclass
|
static Type |
resolveReturnType(Class<?> subclass,
Method method)
Resolves the actual return type of the specified method for the type hierarchy specified by the given subclass
|
static Type |
resolveType(Class<?> subclass,
Field field)
Resolves the actual type of the specified field for the type hierarchy specified by the given subclass
|
static Type |
resolveType(ParameterizedType parameterizedType,
Type metadataType) |
static Type |
resolveType(Type type,
Class<?> subclass,
Member member)
Resolves the actual type of the specified type for the type hierarchy specified by the given subclass
|
static Type |
resolveType(Type type,
Class<?> subclass,
Member member,
Collection<TypeVariable<?>> seen) |
static Type |
resolveType(Type type,
Type actualType,
Collection<TypeVariable<?>> seen) |
static Type[] |
resolveTypes(Type[] types,
Type actualType) |
static Type[] |
resolveTypes(Type[] types,
Type actualType,
Collection<TypeVariable<?>> seen) |
static boolean |
satisfiesDependency(boolean isDelegateOrEvent,
boolean isProducer,
Type injectionPointType,
Type beanType) |
static boolean |
satisfiesDependencyRaw(boolean isDelegateOrEvent,
boolean isProducer,
Type injectionPointType,
Type beanType) |
public static boolean satisfiesDependency(boolean isDelegateOrEvent,
boolean isProducer,
Type injectionPointType,
Type beanType)
public static boolean satisfiesDependencyRaw(boolean isDelegateOrEvent,
boolean isProducer,
Type injectionPointType,
Type beanType)
public static boolean isAssignableFrom(boolean isDelegateOrEvent,
boolean isProducer,
Type requiredType,
Type beanType)
public static boolean containsTypeVariable(Type type)
public static boolean containTypeVariable(Collection<? extends Type> types)
public static boolean containTypeVariable(Type[] types)
public static boolean containsWildcardType(Type type)
type - to checktrue if the given type contains a WildcardType
false otherwisepublic static Type resolveType(Class<?> subclass, Field field)
public static Type resolveReturnType(Class<?> subclass, Method method)
public static Type[] resolveParameterTypes(Class<?> subclass, Constructor<?> constructor)
public static Type[] resolveParameterTypes(Class<?> subclass, Method method)
public static Type resolveType(Type type, Class<?> subclass, Member member)
public static Type resolveType(Type type, Class<?> subclass, Member member, Collection<TypeVariable<?>> seen)
public static Type resolveType(Type type, Type actualType, Collection<TypeVariable<?>> seen)
public static Type[] resolveTypes(Type[] types, Type actualType, Collection<TypeVariable<?>> seen)
public static Set<Type> getTypeClosure(Type type, Type actualType)
Take the following classes:
public class Foo {
private T t;
}
public class Bar extends Foo {
}
To get the type closure of T in the context of Bar (which is {Number.class, Object.class}), you have to call this method like
GenericUtil.getTypeClosure(Foo.class.getDeclaredField("t").getType(), Bar.class, Foo.class);
Take the following classes:
public class Foo {
private T t;
}
public class Bar extends Foo {
}
To get the type closure of Bar
GenericUtil.getTypeClosure(Foo.class, new TypeLiteral>() {}.getType(), Bar.class);
type - the type to get the closure foractualType - the context to bind type variablespublic static boolean hasTypeParameters(Type type)
public static ParameterizedType getParameterizedType(Type type)
public static Type resolveType(ParameterizedType parameterizedType, Type metadataType)
Copyright © 2008–2018 The Apache Software Foundation. All rights reserved.