Class TypeResolver.TypeVariableKey

java.lang.Object
com.google.common.reflect.TypeResolver.TypeVariableKey
Enclosing class:
TypeResolver

static final class TypeResolver.TypeVariableKey extends Object
Wraps around TypeVariable<?> to ensure that any two type variables are equal as long as they are declared by the same GenericDeclaration and have the same name, even if their bounds differ.

While resolving a type variable from a var -> type map, we don't care whether the type variable's bound has been partially resolved. As long as the type variable "identity" matches.

On the other hand, if for example we are resolving List<A extends B> to List<A extends String>, we need to compare that <A extends B> is unequal to <A extends String> in order to decide to use the transformed type instead of the original type.

  • Field Details

  • Constructor Details

  • Method Details

    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(@CheckForNull Object obj)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • forLookup

      @CheckForNull static TypeResolver.TypeVariableKey forLookup(Type t)
      Wraps t in a TypeVariableKey if it's a type variable.
    • equalsType

      boolean equalsType(Type type)
      Returns true if type is a TypeVariable with the same name and declared by the same GenericDeclaration.
    • equalsTypeVariable

      private boolean equalsTypeVariable(TypeVariable<?> that)