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
Modifier and TypeClassDescriptionstatic final class
static final class
static class
static class
-
Field Summary
-
Constructor Summary
-
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
.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 typesstatic boolean
isAssignable
(Type to, Type from) Tests whether afrom
type is assignable toto
typestatic 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) 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
-
-
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 -
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
-
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
-
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:
-
getSimpleName
Returns a simple name for a givenType
- See Also:
-