Interface JsMessageVisitor.ObjectLiteralMap

Enclosing class:
JsMessageVisitor

public static interface JsMessageVisitor.ObjectLiteralMap
Represents the contents of a object literal Node in the AST.

The object literal may not have any computed keys or methods.

Use JsMessageVisitor.extractObjectLiteralMap(Node) to get an instance.

  • Method Summary

    Modifier and Type
    Method
    Description
    void
    checkForRequiredKeys(Set<String> requiredKeys, Function<String,com.google.javascript.jscomp.JsMessageVisitor.MalformedException> createException)
    Throws a JsMessageVisitor.MalformedException if the object literal does not have one all the keys in the required set.
    void
    checkForUnexpectedKeys(Set<String> expectedKeys, Function<String,String> createErrorMessage)
    Throws a JsMessageVisitor.MalformedException if the object literal has keys not in the expected set.
    com.google.common.collect.ImmutableMap<String,String>
    Returns a map from object property names to string values, building it first, if necessary.
    com.google.common.collect.ImmutableMap<String,Node>
    Returns a map from object property names the Node values they have in the AST, building the map first, if necessary.
    boolean
     
    @Nullable Node
    Get the value node for a key.
  • Method Details

    • getBooleanValueOrFalse

      boolean getBooleanValueOrFalse(String key) throws com.google.javascript.jscomp.JsMessageVisitor.MalformedException
      Throws:
      com.google.javascript.jscomp.JsMessageVisitor.MalformedException
    • extractAsValueMap

      com.google.common.collect.ImmutableMap<String,Node> extractAsValueMap()
      Returns a map from object property names the Node values they have in the AST, building the map first, if necessary.
    • extractAsStringToStringMap

      com.google.common.collect.ImmutableMap<String,String> extractAsStringToStringMap() throws com.google.javascript.jscomp.JsMessageVisitor.MalformedException
      Returns a map from object property names to string values, building it first, if necessary.
      Throws:
      com.google.javascript.jscomp.JsMessageVisitor.MalformedException - if any of the values are not actually simple string literals or concatenations of string literals.
    • getValueNode

      @Nullable Node getValueNode(String key)
      Get the value node for a key.

      This method avoids the work of extracting the full value map.

    • checkForUnexpectedKeys

      void checkForUnexpectedKeys(Set<String> expectedKeys, Function<String,String> createErrorMessage) throws com.google.javascript.jscomp.JsMessageVisitor.MalformedException
      Throws a JsMessageVisitor.MalformedException if the object literal has keys not in the expected set.
      Throws:
      com.google.javascript.jscomp.JsMessageVisitor.MalformedException
    • checkForRequiredKeys

      void checkForRequiredKeys(Set<String> requiredKeys, Function<String,com.google.javascript.jscomp.JsMessageVisitor.MalformedException> createException) throws com.google.javascript.jscomp.JsMessageVisitor.MalformedException
      Throws a JsMessageVisitor.MalformedException if the object literal does not have one all the keys in the required set.
      Throws:
      com.google.javascript.jscomp.JsMessageVisitor.MalformedException