Class Types
- java.lang.Object
-
- org.elasticsearch.common.inject.util.Types
-
public final class Types extends java.lang.ObjectStatic methods for working with types.- Since:
- 2.0
-
-
Method Summary
Modifier and Type Method Description static java.lang.reflect.GenericArrayTypearrayOf(java.lang.reflect.Type componentType)Returns an array type whose elements are all instances ofcomponentType.static java.lang.reflect.ParameterizedTypelistOf(java.lang.reflect.Type elementType)Returns a type modelling aListwhose elements are of typeelementType.static java.lang.reflect.ParameterizedTypemapOf(java.lang.reflect.Type keyType, java.lang.reflect.Type valueType)Returns a type modelling aMapwhose keys are of typekeyTypeand whose values are of typevalueType.static java.lang.reflect.ParameterizedTypenewParameterizedType(java.lang.reflect.Type rawType, java.lang.reflect.Type... typeArguments)Returns a new parameterized type, applyingtypeArgumentstorawType.static java.lang.reflect.ParameterizedTypenewParameterizedTypeWithOwner(java.lang.reflect.Type ownerType, java.lang.reflect.Type rawType, java.lang.reflect.Type... typeArguments)Returns a new parameterized type, applyingtypeArgumentstorawTypeand enclosed byownerType.static java.lang.reflect.ParameterizedTypeproviderOf(java.lang.reflect.Type providedType)Returns a type modelling aProviderthat provides elements of typeelementType.static java.lang.reflect.ParameterizedTypesetOf(java.lang.reflect.Type elementType)Returns a type modelling aSetwhose elements are of typeelementType.static java.lang.reflect.WildcardTypesubtypeOf(java.lang.reflect.Type bound)Returns a type that represents an unknown type that extendsbound.static java.lang.reflect.WildcardTypesupertypeOf(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, applyingtypeArgumentstorawType. 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, applyingtypeArgumentstorawTypeand 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, ifboundisCharSequence.class, this returns? extends CharSequence. IfboundisObject.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, ifboundisString.class, this returns? super String.
-
listOf
public static java.lang.reflect.ParameterizedType listOf(java.lang.reflect.Type elementType)
Returns a type modelling aListwhose 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 aSetwhose 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 aMapwhose keys are of typekeyTypeand 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 aProviderthat provides elements of typeelementType.- Returns:
- a parameterized type.
-
-