Class Types
- java.lang.Object
-
- org.elasticsearch.common.inject.util.Types
-
public final class Types extends java.lang.Object
Static methods for working with types.- Since:
- 2.0
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.reflect.GenericArrayType
arrayOf(java.lang.reflect.Type componentType)
Returns an array type whose elements are all instances ofcomponentType
.static java.lang.reflect.ParameterizedType
listOf(java.lang.reflect.Type elementType)
Returns a type modelling aList
whose elements are of typeelementType
.static java.lang.reflect.ParameterizedType
mapOf(java.lang.reflect.Type keyType, java.lang.reflect.Type valueType)
Returns a type modelling aMap
whose keys are of typekeyType
and whose values are of typevalueType
.static java.lang.reflect.ParameterizedType
newParameterizedType(java.lang.reflect.Type rawType, java.lang.reflect.Type... typeArguments)
Returns a new parameterized type, applyingtypeArguments
torawType
.static java.lang.reflect.ParameterizedType
newParameterizedTypeWithOwner(java.lang.reflect.Type ownerType, java.lang.reflect.Type rawType, java.lang.reflect.Type... typeArguments)
Returns a new parameterized type, applyingtypeArguments
torawType
and enclosed byownerType
.static java.lang.reflect.ParameterizedType
providerOf(java.lang.reflect.Type providedType)
Returns a type modelling aProvider
that provides elements of typeelementType
.static java.lang.reflect.ParameterizedType
setOf(java.lang.reflect.Type elementType)
Returns a type modelling aSet
whose elements are of typeelementType
.static java.lang.reflect.WildcardType
subtypeOf(java.lang.reflect.Type bound)
Returns a type that represents an unknown type that extendsbound
.static java.lang.reflect.WildcardType
supertypeOf(java.lang.reflect.Type bound)
Returns a type that represents an unknown supertype ofbound
.
-
-
-
Method Detail
-
newParameterizedType
public static java.lang.reflect.ParameterizedType newParameterizedType(java.lang.reflect.Type rawType, java.lang.reflect.Type... typeArguments)
Returns a new parameterized type, applyingtypeArguments
torawType
. The returned type does not have an owner type.- Returns:
- a parameterized type.
-
newParameterizedTypeWithOwner
public static java.lang.reflect.ParameterizedType newParameterizedTypeWithOwner(java.lang.reflect.Type ownerType, java.lang.reflect.Type rawType, java.lang.reflect.Type... typeArguments)
Returns a new parameterized type, applyingtypeArguments
torawType
and enclosed byownerType
.- Returns:
- a parameterized type.
-
arrayOf
public static java.lang.reflect.GenericArrayType arrayOf(java.lang.reflect.Type componentType)
Returns an array type whose elements are all instances ofcomponentType
.- Returns:
- a generic array type.
-
subtypeOf
public static java.lang.reflect.WildcardType subtypeOf(java.lang.reflect.Type bound)
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
public static java.lang.reflect.WildcardType supertypeOf(java.lang.reflect.Type bound)
Returns a type that represents an unknown supertype ofbound
. For example, ifbound
isString.class
, this returns? super String
.
-
listOf
public static java.lang.reflect.ParameterizedType listOf(java.lang.reflect.Type elementType)
Returns a type modelling aList
whose elements are of typeelementType
.- Returns:
- a parameterized type.
-
setOf
public static java.lang.reflect.ParameterizedType setOf(java.lang.reflect.Type elementType)
Returns a type modelling aSet
whose elements are of typeelementType
.- Returns:
- a parameterized type.
-
mapOf
public static java.lang.reflect.ParameterizedType mapOf(java.lang.reflect.Type keyType, java.lang.reflect.Type valueType)
Returns a type modelling aMap
whose keys are of typekeyType
and whose values are of typevalueType
.- Returns:
- a parameterized type.
-
providerOf
public static java.lang.reflect.ParameterizedType providerOf(java.lang.reflect.Type providedType)
Returns a type modelling aProvider
that provides elements of typeelementType
.- Returns:
- a parameterized type.
-
-