public class MoreTypes
extends java.lang.Object
Types
API.Modifier and Type | Class and Description |
---|---|
private static interface |
MoreTypes.CompositeType
A type formed from other types, such as arrays, parameterized types or wildcard types
|
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 and Description |
---|---|
static java.lang.reflect.Type[] |
EMPTY_TYPE_ARRAY |
private static java.util.Map<TypeLiteral<?>,TypeLiteral<?>> |
PRIMITIVE_TO_WRAPPER |
Modifier | Constructor and Description |
---|---|
private |
MoreTypes() |
Modifier and Type | Method and Description |
---|---|
static java.lang.reflect.Type |
canonicalize(java.lang.reflect.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.
|
private static void |
checkNotPrimitive(java.lang.reflect.Type type,
java.lang.String use) |
private static java.lang.Class<?> |
declaringClassOf(java.lang.reflect.TypeVariable typeVariable)
Returns the declaring class of
typeVariable , or null if it was not declared by
a class. |
static boolean |
equals(java.lang.reflect.Type a,
java.lang.reflect.Type b)
Returns true if
a and b are equal. |
static java.lang.reflect.Type |
getGenericSupertype(java.lang.reflect.Type type,
java.lang.Class<?> rawType,
java.lang.Class<?> toResolve)
Returns the generic supertype for
type . |
static java.lang.Class<?> |
getRawType(java.lang.reflect.Type type) |
private static int |
hashCodeOrZero(java.lang.Object o) |
private static int |
indexOf(java.lang.Object[] array,
java.lang.Object toFind) |
private static boolean |
isFullySpecified(java.lang.reflect.Type type)
Returns true if
type is free from type variables. |
static java.lang.reflect.Type |
resolveTypeVariable(java.lang.reflect.Type type,
java.lang.Class<?> rawType,
java.lang.reflect.TypeVariable unknown) |
static java.lang.String |
typeToString(java.lang.reflect.Type type) |
public static final java.lang.reflect.Type[] EMPTY_TYPE_ARRAY
private static final java.util.Map<TypeLiteral<?>,TypeLiteral<?>> PRIMITIVE_TO_WRAPPER
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 variableprivate static boolean isFullySpecified(java.lang.reflect.Type type)
type
is free from type variables.public static java.lang.reflect.Type canonicalize(java.lang.reflect.Type type)
Object.equals()
. The returned
type is Serializable
.public static java.lang.Class<?> getRawType(java.lang.reflect.Type type)
public static boolean equals(java.lang.reflect.Type a, java.lang.reflect.Type b)
a
and b
are equal.private static int hashCodeOrZero(java.lang.Object o)
public static java.lang.String typeToString(java.lang.reflect.Type type)
public static java.lang.reflect.Type getGenericSupertype(java.lang.reflect.Type type, java.lang.Class<?> rawType, java.lang.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 java.lang.reflect.Type resolveTypeVariable(java.lang.reflect.Type type, java.lang.Class<?> rawType, java.lang.reflect.TypeVariable unknown)
private static int indexOf(java.lang.Object[] array, java.lang.Object toFind)
private static java.lang.Class<?> declaringClassOf(java.lang.reflect.TypeVariable typeVariable)
typeVariable
, or null
if it was not declared by
a class.private static void checkNotPrimitive(java.lang.reflect.Type type, java.lang.String use)