Package org.apache.webbeans.util
Class GenericsUtil
- java.lang.Object
-
- org.apache.webbeans.util.GenericsUtil
-
public final class GenericsUtil extends Object
Utility classes for generic type operations.
-
-
Constructor Summary
Constructors Constructor Description GenericsUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleancontainsTypeVariable(Type type)static booleancontainsWildcardType(Type type)static booleancontainTypeVariable(Type[] types)static booleancontainTypeVariable(Collection<? extends Type> types)static Set<Type>getDirectTypeClosure(Type type, Type actualType)static ParameterizedTypegetParameterizedType(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 booleanhasTypeParameters(Type type)static booleanisAssignableFrom(boolean isDelegateOrEvent, boolean isProducer, Type requiredType, Type beanType, Map<Type,Integer> visited)5.2.3 and 5.2.4static Type[]resolveParameterTypes(Class<?> subclass, Constructor<?> constructor)Resolves the actual parameter types of the specified constructor for the type hierarchy specified by the given subclassstatic Type[]resolveParameterTypes(Class<?> subclass, Method method)Resolves the actual parameter types of the specified method for the type hierarchy specified by the given subclassstatic TyperesolveReturnType(Class<?> subclass, Method method)Resolves the actual return type of the specified method for the type hierarchy specified by the given subclassstatic TyperesolveType(Class<?> subclass, Field field)Resolves the actual type of the specified field for the type hierarchy specified by the given subclassstatic TyperesolveType(ParameterizedType parameterizedType, Type metadataType)static TyperesolveType(Type type, Class<?> subclass, Member member)Resolves the actual type of the specified type for the type hierarchy specified by the given subclassstatic TyperesolveType(Type type, Class<?> subclass, Member member, Collection<TypeVariable<?>> seen)static TyperesolveType(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 booleansatisfiesDependency(boolean isDelegateOrEvent, boolean isProducer, Type injectionPointType, Type beanType, Map<Type,Integer> visited)static booleansatisfiesDependencyRaw(boolean isDelegateOrEvent, boolean isProducer, Type injectionPointType, Type beanType, Map<Type,Integer> visited)
-
-
-
Method Detail
-
satisfiesDependency
public static boolean satisfiesDependency(boolean isDelegateOrEvent, boolean isProducer, Type injectionPointType, Type beanType, Map<Type,Integer> visited)
-
satisfiesDependencyRaw
public static boolean satisfiesDependencyRaw(boolean isDelegateOrEvent, boolean isProducer, Type injectionPointType, Type beanType, Map<Type,Integer> visited)
-
isAssignableFrom
public static boolean isAssignableFrom(boolean isDelegateOrEvent, boolean isProducer, Type requiredType, Type beanType, Map<Type,Integer> visited)5.2.3 and 5.2.4
-
containsTypeVariable
public static boolean containsTypeVariable(Type type)
- Returns:
- true, if the specified type declaration contains an unresolved type variable.
-
containTypeVariable
public static boolean containTypeVariable(Collection<? extends Type> types)
-
containTypeVariable
public static boolean containTypeVariable(Type[] types)
-
containsWildcardType
public static boolean containsWildcardType(Type type)
- Parameters:
type- to check- Returns:
trueif the given type contains aWildcardTypefalseotherwise
-
resolveType
public static Type resolveType(Class<?> subclass, Field field)
Resolves the actual type of the specified field for the type hierarchy specified by the given subclass
-
resolveReturnType
public 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
-
resolveParameterTypes
public 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
-
resolveParameterTypes
public 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
-
resolveType
public 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
-
resolveType
public static Type resolveType(Type type, Class<?> subclass, Member member, Collection<TypeVariable<?>> seen)
-
resolveType
public static Type resolveType(Type type, Type actualType, Collection<TypeVariable<?>> seen)
-
resolveTypes
public static Type[] resolveTypes(Type[] types, Type actualType, Collection<TypeVariable<?>> seen)
-
getTypeClosure
public static Set<Type> getTypeClosure(Type type, Type actualType)
Returns the type closure for the specified parameters.Example 1:
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);Example 2:
Take the following classes:
public class Foo{ private T t; } public class Bar extends Foo { } To get the type closure of Bar
in the context of Foo (which are besides Object.class the ParameterizedTypes Bar and Foo ), you have to call this method like GenericUtil.getTypeClosure(Foo.class, new TypeLiteral>() {}.getType(), Bar.class); - Parameters:
type- the type to get the closure foractualType- the context to bind type variables- Returns:
- the type closure
-
hasTypeParameters
public static boolean hasTypeParameters(Type type)
-
getParameterizedType
public static ParameterizedType getParameterizedType(Type type)
-
resolveType
public static Type resolveType(ParameterizedType parameterizedType, Type metadataType)
-
-