Package com.google.inject.util
Class Types
java.lang.Object
com.google.inject.util.Types
Static methods for working with types.
- Since:
- 2.0
- Author:
- crazybob@google.com (Bob Lee)
-
Method Summary
Modifier and TypeMethodDescriptionstatic GenericArrayTypeReturns an array type whose elements are all instances ofcomponentType.static ParameterizedTypecollectionOf(Type elementType) Returns a type modelling aCollectionwhose elements are of typeelementType.static TypejakartaProviderOf(Type type) Returns a type modelling aProviderthat provides elements of typeelementType.static TypejavaxProviderOf(Type type) Returns a type modelling aProviderthat provides elements of typeelementType.static ParameterizedTypeReturns a type modelling aListwhose elements are of typeelementType.static ParameterizedTypeReturns a type modelling aMapwhose keys are of typekeyTypeand whose values are of typevalueType.static ParameterizedTypenewParameterizedType(Type rawType, Type... typeArguments) Returns a new parameterized type, applyingtypeArgumentstorawType.static ParameterizedTypenewParameterizedTypeWithOwner(Type ownerType, Type rawType, Type... typeArguments) Returns a new parameterized type, applyingtypeArgumentstorawTypeand enclosed byownerType.static ParameterizedTypeproviderOf(Type providedType) Returns a type modelling aProviderthat provides elements of typeelementType.static ParameterizedTypeReturns a type modelling aSetwhose elements are of typeelementType.static WildcardTypeReturns a type that represents an unknown type that extendsbound.static WildcardTypesupertypeOf(Type bound) Returns a type that represents an unknown supertype ofbound.
-
Method Details
-
newParameterizedType
Returns a new parameterized type, applyingtypeArgumentstorawType. The returned type does not have an owner type.- Returns:
- a
serializableparameterized type.
-
newParameterizedTypeWithOwner
public static ParameterizedType newParameterizedTypeWithOwner(Type ownerType, Type rawType, Type... typeArguments) Returns a new parameterized type, applyingtypeArgumentstorawTypeand enclosed byownerType.- Returns:
- a
serializableparameterized type.
-
arrayOf
Returns an array type whose elements are all instances ofcomponentType.- Returns:
- a
serializablegeneric array type.
-
subtypeOf
Returns a type that represents an unknown type that extendsbound. For example, ifboundisCharSequence.class, this returns? extends CharSequence. IfboundisObject.class, this returns?, which is shorthand for? extends Object. -
supertypeOf
Returns a type that represents an unknown supertype ofbound. For example, ifboundisString.class, this returns? super String. -
listOf
Returns a type modelling aListwhose elements are of typeelementType.- Returns:
- a
serializableparameterized type.
-
collectionOf
Returns a type modelling aCollectionwhose elements are of typeelementType.- Returns:
- a
serializableparameterized type.
-
setOf
Returns a type modelling aSetwhose elements are of typeelementType.- Returns:
- a
serializableparameterized type.
-
mapOf
Returns a type modelling aMapwhose keys are of typekeyTypeand whose values are of typevalueType.- Returns:
- a
serializableparameterized type.
-
providerOf
Returns a type modelling aProviderthat provides elements of typeelementType.- Returns:
- a
serializableparameterized type.
-
javaxProviderOf
Returns a type modelling aProviderthat provides elements of typeelementType.- Returns:
- a
serializableparameterized type.
-
jakartaProviderOf
Returns a type modelling aProviderthat provides elements of typeelementType.- Returns:
- a
serializableparameterized type. - Since:
- 6.0
-