Top Description Constructors Methods
com.google.inject.util

public final Class Types

extends Object
Class Inheritance
Imports
com.google.inject.Provider, com.google.inject.internal.MoreTypes, .MoreTypes.GenericArrayTypeImpl, .MoreTypes.ParameterizedTypeImpl, .MoreTypes.WildcardTypeImpl, java.lang.reflect.GenericArrayType, .ParameterizedType, .Type, .WildcardType, java.util.Collection, .List, .Map, .Set

Static methods for working with types.
Author
[email protected] (Bob Lee)
Since
2.0

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static GenericArrayType

Returns:

a serializable generic array type.
arrayOf
(Type componentType)

Returns an array type whose elements are all instances of componentType.

public static ParameterizedType

Returns:

a serializable parameterized type.
collectionOf
(Type elementType)

Returns a type modelling a Collection whose elements are of type elementType.

public static Type

Returns:

a serializable parameterized type.
jakartaProviderOf
(Type type)

Returns a type modelling a jakarta.inject.Provider that provides elements of type elementType.

public static ParameterizedType

Returns:

a serializable parameterized type.
listOf
(Type elementType)

Returns a type modelling a List whose elements are of type elementType.

public static ParameterizedType

Returns:

a serializable parameterized type.
mapOf
(Type keyType, Type valueType)

Returns a type modelling a Map whose keys are of type keyType and whose values are of type valueType.

public static ParameterizedType

Returns:

a serializable parameterized type.
newParameterizedType
(Type rawType, Type... typeArguments)

Returns a new parameterized type, applying typeArguments to rawType.

public static ParameterizedType

Returns:

a serializable parameterized type.
newParameterizedTypeWithOwner
(Type ownerType, Type rawType, Type... typeArguments)

Returns a new parameterized type, applying typeArguments to rawType and enclosed by ownerType.

public static ParameterizedType

Returns:

a serializable parameterized type.
providerOf
(Type providedType)

Returns a type modelling a Provider that provides elements of type elementType.

public static ParameterizedType

Returns:

a serializable parameterized type.
setOf
(Type elementType)

Returns a type modelling a Set whose elements are of type elementType.

public static WildcardType
subtypeOf(Type bound)

Returns a type that represents an unknown type that extends bound.

public static WildcardType
supertypeOf(Type bound)

Returns a type that represents an unknown supertype of bound.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

Typesback to summary
private Types()

Method Detail

arrayOfback to summary
public static GenericArrayType arrayOf(Type componentType)

Returns an array type whose elements are all instances of componentType.

Returns:GenericArrayType

a serializable generic array type.

collectionOfback to summary
public static ParameterizedType collectionOf(Type elementType)

Returns a type modelling a Collection whose elements are of type elementType.

Returns:ParameterizedType

a serializable parameterized type.

jakartaProviderOfback to summary
public static Type jakartaProviderOf(Type type)

Returns a type modelling a jakarta.inject.Provider that provides elements of type elementType.

Returns:Type

a serializable parameterized type.

Since
6.0
listOfback to summary
public static ParameterizedType listOf(Type elementType)

Returns a type modelling a List whose elements are of type elementType.

Returns:ParameterizedType

a serializable parameterized type.

mapOfback to summary
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:ParameterizedType

a serializable parameterized type.

newParameterizedTypeback to summary
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:ParameterizedType

a serializable parameterized type.

newParameterizedTypeWithOwnerback to summary
public static ParameterizedType newParameterizedTypeWithOwner(Type ownerType, Type rawType, Type... typeArguments)

Returns a new parameterized type, applying typeArguments to rawType and enclosed by ownerType.

Returns:ParameterizedType

a serializable parameterized type.

providerOfback to summary
public static ParameterizedType providerOf(Type providedType)

Returns a type modelling a Provider that provides elements of type elementType.

Returns:ParameterizedType

a serializable parameterized type.

setOfback to summary
public static ParameterizedType setOf(Type elementType)

Returns a type modelling a Set whose elements are of type elementType.

Returns:ParameterizedType

a serializable parameterized type.

subtypeOfback to summary
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.

supertypeOfback to summary
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.