Package com.google.inject.internal
Class MoreTypes
- java.lang.Object
-
- com.google.inject.internal.MoreTypes
-
public class MoreTypes extends Object
Static methods for working with types that we aren't publishing in the publicTypesAPI.- Author:
- jessewilson@google.com (Jesse Wilson)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classMoreTypes.GenericArrayTypeImplstatic classMoreTypes.ParameterizedTypeImplstatic classMoreTypes.WildcardTypeImplThe WildcardType interface supports multiple upper bounds and multiple lower bounds.
-
Field Summary
Fields Modifier and Type Field Description static Type[]EMPTY_TYPE_ARRAY
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Typecanonicalize(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.static booleanequals(Type a, Type b)Returns true ifaandbare equal.static TypegetGenericSupertype(Type type, Class<?> rawType, Class<?> toResolve)Returns the generic supertype fortype.static Class<?>getRawType(Type type)static TyperesolveTypeVariable(Type type, Class<?> rawType, TypeVariable<?> unknown)static StringtypeToString(Type type)
-
-
-
Field Detail
-
EMPTY_TYPE_ARRAY
public static final Type[] EMPTY_TYPE_ARRAY
-
-
Method Detail
-
canonicalizeKey
public static <T> Key<T> canonicalizeKey(Key<T> key)
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
public static <T> TypeLiteral<T> canonicalizeForKey(TypeLiteral<T> typeLiteral)
Returns an type that's appropriate for use in a key.If the raw type of
typeLiteralis ajavax.inject.Provider, this returns acom.google.inject.Providerwith the same type parameters.If the type is a primitive, the corresponding wrapper type will be returned.
- Throws:
ConfigurationException- iftypecontains a type variable
-
canonicalize
public static Type canonicalize(Type type)
Returns a type that is functionally equal but not necessarily equal according toObject.equals(). The returned type isSerializable.
-
getGenericSupertype
public static Type getGenericSupertype(Type type, Class<?> rawType, Class<?> toResolve)
Returns the generic supertype fortype. For example, given a classIntegerSet, the result for when supertype isSet.classisSet<Integer>and the result when the supertype isCollection.classisCollection<Integer>.
-
resolveTypeVariable
public static Type resolveTypeVariable(Type type, Class<?> rawType, TypeVariable<?> unknown)
-
-