Package com.google.javascript.jscomp
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
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
checkForRequiredKeys(java.util.Set<java.lang.String> requiredKeys, java.util.function.Function<java.lang.String,com.google.javascript.jscomp.JsMessageVisitor.MalformedException> createException)
Throws aJsMessageVisitor.MalformedException
if the object literal does not have one all the keys in the required set.void
checkForUnexpectedKeys(java.util.Set<java.lang.String> expectedKeys, java.util.function.Function<java.lang.String,java.lang.String> createErrorMessage)
Throws aJsMessageVisitor.MalformedException
if the object literal has keys not in the expected set.com.google.common.collect.ImmutableMap<java.lang.String,java.lang.String>
extractStringToStringMap()
Returns a map from object property names to string values, building it first, if necessary.com.google.common.collect.ImmutableMap<java.lang.String,Node>
extractValueMap()
Returns a map from object property names the Node values they have in the AST, building the map first, if necessary.boolean
getBooleanValueOrFalse(java.lang.String key)
@Nullable Node
getValueNode(java.lang.String key)
Get the value node for a key.
-
-
-
Method Detail
-
getBooleanValueOrFalse
boolean getBooleanValueOrFalse(java.lang.String key) throws com.google.javascript.jscomp.JsMessageVisitor.MalformedException
- Throws:
com.google.javascript.jscomp.JsMessageVisitor.MalformedException
-
extractValueMap
com.google.common.collect.ImmutableMap<java.lang.String,Node> extractValueMap()
Returns a map from object property names the Node values they have in the AST, building the map first, if necessary.
-
extractStringToStringMap
com.google.common.collect.ImmutableMap<java.lang.String,java.lang.String> extractStringToStringMap() 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(java.lang.String key)
Get the value node for a key.This method avoids the work of extracting the full value map.
-
checkForUnexpectedKeys
void checkForUnexpectedKeys(java.util.Set<java.lang.String> expectedKeys, java.util.function.Function<java.lang.String,java.lang.String> createErrorMessage) throws com.google.javascript.jscomp.JsMessageVisitor.MalformedException
Throws aJsMessageVisitor.MalformedException
if the object literal has keys not in the expected set.- Throws:
com.google.javascript.jscomp.JsMessageVisitor.MalformedException
-
checkForRequiredKeys
void checkForRequiredKeys(java.util.Set<java.lang.String> requiredKeys, java.util.function.Function<java.lang.String,com.google.javascript.jscomp.JsMessageVisitor.MalformedException> createException) throws com.google.javascript.jscomp.JsMessageVisitor.MalformedException
Throws aJsMessageVisitor.MalformedException
if the object literal does not have one all the keys in the required set.- Throws:
com.google.javascript.jscomp.JsMessageVisitor.MalformedException
-
-