org.elasticsearch.common.inject.util
Class Types

java.lang.Object
  extended by org.elasticsearch.common.inject.util.Types

public final class Types
extends Object

Static methods for working with types.

Since:
2.0
Author:
crazybob@google.com (Bob Lee)

Method Summary
static GenericArrayType arrayOf(Type componentType)
          Returns an array type whose elements are all instances of componentType.
static ParameterizedType listOf(Type elementType)
          Returns a type modelling a List whose elements are of type elementType.
static ParameterizedType mapOf(Type keyType, Type valueType)
          Returns a type modelling a Map whose keys are of type keyType and whose values are of type valueType.
static ParameterizedType newParameterizedType(Type rawType, Type... typeArguments)
          Returns a new parameterized type, applying typeArguments to rawType.
static ParameterizedType newParameterizedTypeWithOwner(Type ownerType, Type rawType, Type... typeArguments)
          Returns a new parameterized type, applying typeArguments to rawType and enclosed by ownerType.
static ParameterizedType providerOf(Type providedType)
          Returns a type modelling a Provider that provides elements of type elementType.
static ParameterizedType setOf(Type elementType)
          Returns a type modelling a Set whose elements are of type elementType.
static WildcardType subtypeOf(Type bound)
          Returns a type that represents an unknown type that extends bound.
static WildcardType supertypeOf(Type bound)
          Returns a type that represents an unknown supertype of bound.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

newParameterizedType

public static ParameterizedType newParameterizedType(Type rawType,
                                                     Type... typeArguments)
Returns a new parameterized type, applying typeArguments to rawType. The returned type does not have an owner type.

Returns:
a serializable parameterized type.

newParameterizedTypeWithOwner

public static ParameterizedType newParameterizedTypeWithOwner(Type ownerType,
                                                              Type rawType,
                                                              Type... typeArguments)
Returns a new parameterized type, applying typeArguments to rawType and enclosed by ownerType.

Returns:
a serializable parameterized type.

arrayOf

public static GenericArrayType arrayOf(Type componentType)
Returns an array type whose elements are all instances of componentType.

Returns:
a serializable generic array type.

subtypeOf

public static WildcardType subtypeOf(Type bound)
Returns a type that represents an unknown type that extends bound. For example, if bound is CharSequence.class, this returns ? extends CharSequence. If bound is Object.class, this returns ?, which is shorthand for ? extends Object.


supertypeOf

public static WildcardType supertypeOf(Type bound)
Returns a type that represents an unknown supertype of bound. For example, if bound is String.class, this returns ? super String.


listOf

public static ParameterizedType listOf(Type elementType)
Returns a type modelling a List whose elements are of type elementType.

Returns:
a serializable parameterized type.

setOf

public static ParameterizedType setOf(Type elementType)
Returns a type modelling a Set whose elements are of type elementType.

Returns:
a serializable parameterized type.

mapOf

public static ParameterizedType mapOf(Type keyType,
                                      Type valueType)
Returns a type modelling a Map whose keys are of type keyType and whose values are of type valueType.

Returns:
a serializable parameterized type.

providerOf

public static ParameterizedType providerOf(Type providedType)
Returns a type modelling a Provider that provides elements of type elementType.

Returns:
a serializable parameterized type.


Copyright © 2009-2012. All Rights Reserved.