com.google.inject.internal
Class MoreTypes

java.lang.Object
  extended by com.google.inject.internal.MoreTypes

public class MoreTypes
extends Object

Static methods for working with types that we aren't publishing in the public Types API.

Author:
jessewilson@google.com (Jesse Wilson)

Nested Class Summary
static class MoreTypes.GenericArrayTypeImpl
           
static class MoreTypes.ParameterizedTypeImpl
           
static class MoreTypes.WildcardTypeImpl
          The WildcardType interface supports multiple upper bounds and multiple lower bounds.
 
Field Summary
static Type[] EMPTY_TYPE_ARRAY
           
 
Method Summary
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 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 supertype.
static Class<?> getRawType(Type type)
           
static Type resolveTypeVariable(Type type, Class<?> rawType, TypeVariable unknown)
           
static String typeToString(Type type)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMPTY_TYPE_ARRAY

public static final Type[] EMPTY_TYPE_ARRAY
Method Detail

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 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.

Throws:
ConfigurationException - if type contains a type variable

canonicalize

public static Type canonicalize(Type type)
Returns a type that is functionally equal but not necessarily equal according to Object.equals(). The returned type is Serializable.


getRawType

public static Class<?> getRawType(Type type)

equals

public static boolean equals(Type a,
                             Type b)
Returns true if a and b are equal.


typeToString

public static String typeToString(Type type)

getGenericSupertype

public static Type getGenericSupertype(Type type,
                                       Class<?> rawType,
                                       Class<?> toResolve)
Returns the generic supertype for supertype. 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>.


resolveTypeVariable

public static Type resolveTypeVariable(Type type,
                                       Class<?> rawType,
                                       TypeVariable unknown)


Copyright © 2006-2013 Google, Inc.. All Rights Reserved.