Class TemplateTypeMap

java.lang.Object
com.google.javascript.rhino.jstype.TemplateTypeMap

public final class TemplateTypeMap extends Object
Manages a mapping from TemplateType to its resolved JSType. Provides utility methods for cloning/extending the map.
  • Method Details

    • copyWithExtension

      public TemplateTypeMap copyWithExtension(TemplateTypeMap extension)
      Create a new map in which the keys and values have been extended by extension.

      Before extension, any unfilled values in the initial map will be filled with `?`.

    • copyWithExtension

      public TemplateTypeMap copyWithExtension(com.google.common.collect.ImmutableList<TemplateType> keys, com.google.common.collect.ImmutableList<JSType> values)
      Create a new map in which the keys and values have been extended by keys and values respectively.

      Before extension, any unfilled values in the initial map will be filled with `?`.

    • size

      public int size()
    • isEmpty

      public boolean isEmpty()
      Returns true if the map is empty; false otherwise.
    • getTemplateKeys

      public com.google.common.collect.ImmutableList<TemplateType> getTemplateKeys()
      Returns a list of all template keys.
    • getTemplateValues

      public com.google.common.collect.ImmutableList<JSType> getTemplateValues()
    • hasTemplateKey

      public boolean hasTemplateKey(TemplateType templateKey)
      Returns true if this map contains the specified template key, false otherwise.
    • hasTemplateType

      public boolean hasTemplateType(TemplateType key)
      Returns true if there is a JSType value associated with the specified template key; false otherwise.
    • getLastTemplateTypeKeyByName

      public @Nullable TemplateType getLastTemplateTypeKeyByName(String keyName)
      Returns the final template key matching this name in the ordered list of template keys

      Caution: there may be multiple template keys with the same name. Before using this method, consider whether you really want reference name string equality over TemplateType identity- based equality.

    • getResolvedTemplateType

      public JSType getResolvedTemplateType(TemplateType key)
      Returns the JSType value associated with the specified template key. If no JSType value is associated, returns the upper bound for generic, UNKNOWN_TYPE if unspecified.
    • toString

      public String toString()
      Overrides:
      toString in class Object