public class MoreTypes extends Object
Types
API.Modifier and Type | Class | Description |
---|---|---|
static class |
MoreTypes.GenericArrayTypeImpl |
|
static class |
MoreTypes.ParameterizedTypeImpl |
|
static class |
MoreTypes.WildcardTypeImpl |
The WildcardType interface supports multiple upper bounds and multiple lower bounds.
|
Modifier and Type | Field | Description |
---|---|---|
static Type[] |
EMPTY_TYPE_ARRAY |
Modifier and Type | Method | Description |
---|---|---|
static Type |
canonicalize(Type type) |
Returns a type that is functionally equal but not necessarily equal according to
Object.equals() . |
static <T> TypeLiteral<T> |
canonicalizeForKey(TypeLiteral<T> typeLiteral) |
Returns an type that's appropriate for use in a key.
|
static <T> Key<T> |
canonicalizeKey(Key<T> key) |
Returns a key that doesn't hold any references to parent classes.
|
static boolean |
equals(Type a,
Type b) |
Returns true if
a and b are equal. |
static Type |
getGenericSupertype(Type type,
Class<?> rawType,
Class<?> toResolve) |
Returns the generic supertype for
type . |
static Class<?> |
getRawType(Type type) |
|
static Type |
resolveTypeVariable(Type type,
Class<?> rawType,
TypeVariable unknown) |
|
static String |
typeToString(Type type) |
public static final Type[] EMPTY_TYPE_ARRAY
public static <T> Key<T> canonicalizeKey(Key<T> key)
public static <T> TypeLiteral<T> canonicalizeForKey(TypeLiteral<T> typeLiteral)
If the raw type of typeLiteral
is a javax.inject.Provider
, this returns a
com.google.inject.Provider
with the same type parameters.
If the type is a primitive, the corresponding wrapper type will be returned.
ConfigurationException
- if type
contains a type variablepublic static Type canonicalize(Type type)
Object.equals()
. The returned type is Serializable
.public static Type getGenericSupertype(Type type, Class<?> rawType, Class<?> toResolve)
type
. For example, given a class IntegerSet
,
the result for when supertype is Set.class
is Set<Integer>
and the result when
the supertype is Collection.class
is Collection<Integer>
.public static Type resolveTypeVariable(Type type, Class<?> rawType, TypeVariable unknown)
Copyright © 2006–2018 Google, Inc.. All rights reserved.