Package com.google.inject.internal
Class MoreTypes
java.lang.Object
com.google.inject.internal.MoreTypes
Static methods for working with types that we aren't publishing in the public
Types
API.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static interface
A type formed from other types, such as arrays, parameterized types or wildcard typesstatic class
static class
static class
The WildcardType interface supports multiple upper bounds and multiple lower bounds. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Type[]
private static final com.google.common.collect.ImmutableMap<TypeLiteral<?>,
TypeLiteral<?>> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Type
canonicalize
(Type type) Returns a type that is functionally equal but not necessarily equal according toObject.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
(Type type, String use) private static Class<?>
declaringClassOf
(TypeVariable typeVariable) Returns the declaring class oftypeVariable
, ornull
if it was not declared by a class.static boolean
Returns true ifa
andb
are equal.static Type
getGenericSupertype
(Type type, Class<?> rawType, Class<?> toResolve) Returns the generic supertype fortype
.static Class<?>
getRawType
(Type type) private static int
private static int
private static boolean
isFullySpecified
(Type type) Returns true iftype
is free from type variables.static Type
resolveTypeVariable
(Type type, Class<?> rawType, TypeVariable unknown) static String
typeToString
(Type type)
-
Field Details
-
EMPTY_TYPE_ARRAY
-
PRIMITIVE_TO_WRAPPER
private static final com.google.common.collect.ImmutableMap<TypeLiteral<?>,TypeLiteral<?>> PRIMITIVE_TO_WRAPPER
-
-
Constructor Details
-
MoreTypes
private MoreTypes()
-
-
Method Details
-
canonicalizeKey
Returns a key that doesn't hold any references to parent classes. This is necessary for anonymous keys, so ensure we don't hold a ref to the containing module (or class) forever. -
canonicalizeForKey
Returns an type that's appropriate for use in a key.If the raw type of
typeLiteral
is ajavax.inject.Provider
, this returns acom.google.inject.Provider
with the same type parameters.If the type is a primitive, the corresponding wrapper type will be returned.
- Throws:
ConfigurationException
- iftype
contains a type variable
-
isFullySpecified
Returns true iftype
is free from type variables. -
canonicalize
Returns a type that is functionally equal but not necessarily equal according toObject.equals()
. The returned type isSerializable
. -
getRawType
-
equals
Returns true ifa
andb
are equal. -
hashCodeOrZero
-
typeToString
-
getGenericSupertype
Returns the generic supertype fortype
. For example, given a classIntegerSet
, the result for when supertype isSet.class
isSet<Integer>
and the result when the supertype isCollection.class
isCollection<Integer>
. -
resolveTypeVariable
-
indexOf
-
declaringClassOf
Returns the declaring class oftypeVariable
, ornull
if it was not declared by a class. -
checkNotPrimitive
-