Class Types
java.lang.Object
org.elasticsearch.common.inject.util.Types
Static methods for working with types.
- Since:
- 2.0
-
Method Summary
Modifier and TypeMethodDescriptionstatic GenericArrayType
Returns an array type whose elements are all instances ofcomponentType
.static ParameterizedType
Returns a type modelling aList
whose elements are of typeelementType
.static ParameterizedType
Returns a type modelling aMap
whose keys are of typekeyType
and whose values are of typevalueType
.static ParameterizedType
newParameterizedType(Type rawType, Type... typeArguments)
Returns a new parameterized type, applyingtypeArguments
torawType
.static ParameterizedType
newParameterizedTypeWithOwner(Type ownerType, Type rawType, Type... typeArguments)
Returns a new parameterized type, applyingtypeArguments
torawType
and enclosed byownerType
.static ParameterizedType
providerOf(Type providedType)
Returns a type modelling aProvider
that provides elements of typeelementType
.static ParameterizedType
Returns a type modelling aSet
whose elements are of typeelementType
.static WildcardType
Returns a type that represents an unknown type that extendsbound
.static WildcardType
supertypeOf(Type bound)
Returns a type that represents an unknown supertype ofbound
.
-
Method Details
-
newParameterizedType
Returns a new parameterized type, applyingtypeArguments
torawType
. The returned type does not have an owner type.- Returns:
- a parameterized type.
-
newParameterizedTypeWithOwner
public static ParameterizedType newParameterizedTypeWithOwner(Type ownerType, Type rawType, Type... typeArguments)Returns a new parameterized type, applyingtypeArguments
torawType
and enclosed byownerType
.- Returns:
- a parameterized type.
-
arrayOf
Returns an array type whose elements are all instances ofcomponentType
.- Returns:
- a generic array type.
-
subtypeOf
Returns a type that represents an unknown type that extendsbound
. For example, ifbound
isCharSequence.class
, this returns? extends CharSequence
. Ifbound
isObject.class
, this returns?
, which is shorthand for? extends Object
. -
supertypeOf
Returns a type that represents an unknown supertype ofbound
. For example, ifbound
isString.class
, this returns? super String
. -
listOf
Returns a type modelling aList
whose elements are of typeelementType
.- Returns:
- a parameterized type.
-
setOf
Returns a type modelling aSet
whose elements are of typeelementType
.- Returns:
- a parameterized type.
-
mapOf
Returns a type modelling aMap
whose keys are of typekeyType
and whose values are of typevalueType
.- Returns:
- a parameterized type.
-
providerOf
Returns a type modelling aProvider
that provides elements of typeelementType
.- Returns:
- a parameterized type.
-