Class TypeVar

  • All Implemented Interfaces:
    Type

    public class TypeVar
    extends java.lang.Object
    implements Type
    Type variable (e.g. 'a).
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static char[] ALPHAS  
      private static com.google.common.cache.LoadingCache<java.lang.Integer,​java.lang.String> NAME_CACHE  
      (package private) int ordinal  
    • Constructor Summary

      Constructors 
      Constructor Description
      TypeVar​(int ordinal)
      Creates a type variable with a given ordinal.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      <R> R accept​(TypeVisitor<R> typeVisitor)  
      Type copy​(TypeSystem typeSystem, java.util.function.Function<Type,​Type> transform)
      Copies this type, applying a given transform to component types, and returning the original type if the component types are unchanged.
      java.lang.String description()
      Description of the type, e.g.
      private static java.lang.String name​(int i)
      Generates a name for a type variable.
      Op op()
      Type operator.
      java.lang.String toString()
      Returns a string for debugging; see also description().
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • ALPHAS

        private static final char[] ALPHAS
      • NAME_CACHE

        private static final com.google.common.cache.LoadingCache<java.lang.Integer,​java.lang.String> NAME_CACHE
      • ordinal

        final int ordinal
    • Constructor Detail

      • TypeVar

        public TypeVar​(int ordinal)
        Creates a type variable with a given ordinal.

        TypeVar.of(0) returns "'a"; TypeVar.of(1) returns "'b", etc.

    • Method Detail

      • toString

        public java.lang.String toString()
        Returns a string for debugging; see also description().
        Overrides:
        toString in class java.lang.Object
      • name

        private static java.lang.String name​(int i)
        Generates a name for a type variable.

        0 → 'a, 1 → 'b, 26 → 'z, 27 → 'ba, 28 → 'bb, 675 → 'zz, 676 → 'baa, etc. (Think of it is a base 26 number, with "a" as 0, "z" as 25.)

      • description

        public java.lang.String description()
        Description copied from interface: Type
        Description of the type, e.g. "int", "int -> int".
        Specified by:
        description in interface Type
      • op

        public Op op()
        Description copied from interface: Type
        Type operator.
        Specified by:
        op in interface Type
      • copy

        public Type copy​(TypeSystem typeSystem,
                         java.util.function.Function<Type,​Type> transform)
        Description copied from interface: Type
        Copies this type, applying a given transform to component types, and returning the original type if the component types are unchanged.
        Specified by:
        copy in interface Type