Package org.apache.maven.di.impl
Class Types
java.lang.Object
org.apache.maven.di.impl.Types
Various helper methods for type processing
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final class
static final class
static class
static class
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Type[]
private static final Map
<Type, Map<TypeVariable<?>, Type>> static final WildcardType
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Type
bind
(Type type, Function<TypeVariable<?>, Type> bindings) Binds a given type with actual type argumentsstatic Type
bind
(Type type, Map<TypeVariable<?>, Type> bindings) Binds a given type with actual type argumentsstatic GenericArrayType
genericArrayType
(Type componentType) Creates an instance ofGenericArrayType
with a given component typestatic Type[]
getActualTypeArguments
(Type type) Returns an array of actual type arguments for a givenType
getAllSuperTypes
(Type original) Get all super classes and interface implemented by the given type.static Map
<TypeVariable<?>, Type> getAllTypeBindings
(Type type) Returns a map of all type bindings for a givenType
.private static void
getAllTypeBindingsImpl
(Type type, Map<TypeVariable<?>, Type> mapping) static Class
<?> getRawType
(Type type) static String
getSimpleName
(Type type) Returns a simple name for a givenType
static Map
<TypeVariable<?>, Type> getTypeBindings
(Type type) Returns a map of type bindings for a givenType
static Type
getUppermostType
(Type[] types) Returns the most common type among given typesprivate static boolean
isAllObjects
(Type[] types) private static boolean
isAssignable
(Class<?> toRawClazz, Type[] toTypeArguments, Type from, boolean strict) static boolean
isAssignable
(Type to, Type from) Tests whether afrom
type is assignable toto
typeprivate static boolean
isAssignable
(Type to, Type from, boolean strict) static ParameterizedType
parameterizedType
(Class<?> rawType, Type... parameters) Creates an instance ofParameterizedType
static ParameterizedType
parameterizedType
(Type ownerType, Type rawType, Type[] parameters) Creates an instance ofParameterizedType
static Type
simplifyType
(Type original) private static Type[]
simplifyTypes
(Type[] original) private static String
static WildcardType
wildcardType
(Type[] upperBounds, Type[] lowerBounds) Creates an instance ofWildcardType
bound by upper and lower boundsstatic WildcardType
Returns an instance ofWildcardType
that matches any typestatic WildcardType
wildcardTypeExtends
(Type upperBound) Creates an instance ofWildcardType
bound by a single upper boundstatic WildcardType
wildcardTypeSuper
(Type lowerBound) Creates an instance ofWildcardType
bound by a single lower bound
-
Field Details
-
NO_TYPES
-
WILDCARD_TYPE_ANY
-
TYPE_BINDINGS_CACHE
-
-
Constructor Details
-
Types
public Types()
-
-
Method Details
-
getRawType
Returns a rawClass
for a givenType
.A type can be any of
Class
,ParameterizedType
,WildcardType
,GenericArrayType
orTypeVariable
-
getUppermostType
Returns the most common type among given types -
getActualTypeArguments
Returns an array of actual type arguments for a givenType
- Parameters:
type
- type whose actual type arguments should be retrieved- Returns:
- an array of actual type arguments for a given
Type
-
getTypeBindings
Returns a map of type bindings for a givenType
-
getAllTypeBindings
Returns a map of all type bindings for a givenType
. Includes type bindings from a whole class hierarchy -
getAllTypeBindingsImpl
-
bind
Binds a given type with actual type arguments- Parameters:
type
- a type to be boundbindings
- a map of actual types
-
bind
Binds a given type with actual type arguments- Parameters:
type
- a type to be boundbindings
- a lookup function for actual types
-
parameterizedType
public static ParameterizedType parameterizedType(@Nullable Type ownerType, Type rawType, Type[] parameters) Creates an instance ofParameterizedType
- Parameters:
ownerType
- an owner typerawType
- a type to be parameterizedparameters
- parameter types- Returns:
- an instance of
ParameterizedType
-
parameterizedType
Creates an instance ofParameterizedType
- See Also:
-
getAllSuperTypes
Get all super classes and interface implemented by the given type. -
simplifyType
-
simplifyTypes
-
isAllObjects
-
isAssignable
Tests whether afrom
type is assignable toto
type- Parameters:
to
- a 'to' type that should be checked for possible assignmentfrom
- a 'from' type that should be checked for possible assignment- Returns:
- whether an object of type
from
is assignable to an object of typeto
-
isAssignable
-
isAssignable
-
wildcardType
Creates an instance ofWildcardType
bound by upper and lower bounds- Parameters:
upperBounds
- a wildcard upper bound typeslowerBounds
- a wildcard lower bound types- Returns:
- an instance of
WildcardType
-
wildcardTypeAny
Returns an instance ofWildcardType
that matches any typeE.g.
<?>
- See Also:
-
wildcardTypeExtends
Creates an instance ofWildcardType
bound by a single upper boundE.g.
<? extends UpperBound>
- Parameters:
upperBound
- a wildcard upper bound type- Returns:
- an instance of
WildcardType
- See Also:
-
wildcardTypeSuper
Creates an instance ofWildcardType
bound by a single lower boundE.g.
<? super LowerBound>
- Parameters:
lowerBound
- a wildcard lower bound type- Returns:
- an instance of
WildcardType
- See Also:
-
genericArrayType
Creates an instance ofGenericArrayType
with a given component typeSame as
T[]
- Parameters:
componentType
- a component type of generic array- Returns:
- an instance of
GenericArrayType
- See Also:
-
toString
-
getSimpleName
Returns a simple name for a givenType
- See Also:
-