@ParametersAreNonnullByDefault public interface SoyMap extends SoyValue
This is a new interface (compared to SoyLegacyObjectMap) that was designed for
supporting proto map. There are two different Soy map types, one uses ES6 map in JS, and another
uses plain object. This interface tries to use the same APIs as regular Java maps.
Notably this interface and SoyMap has completely different APIs. In JS backends, these two different Soy map types are not interoperable during the runtime. We need to mimic this behavior in other backends. Therefore, in Java backends, if we are unsure about the runtime type of the map instances (since they are all Java maps), the first time the map is accessed (via one set of APIs), we set the state of map type to the one corresponding to the APIs. If the map is accessed later via a different set of APIs, a run time exception will be thrown.
| Modifier and Type | Method and Description |
|---|---|
Map<? extends SoyValue,? extends SoyValueProvider> |
asJavaMap()
Gets a Java map of all items in this SoyMap, where mappings are value to value provider.
|
boolean |
containsKey(SoyValue key)
Checks whether this SoyMap has an item with the given key.
|
SoyValue |
get(SoyValue key)
Gets an item value of this SoyMap.
|
SoyValueProvider |
getProvider(SoyValue key)
Gets a provider of an item value of this SoyMap.
|
Iterable<? extends SoyValue> |
keys()
Gets an iterable over all item keys in this SoyMap.
|
int |
size()
Gets the number of items in this SoyMap.
|
booleanValue, coerceToBoolean, coerceToString, equals, floatValue, integerValue, longValue, numberValue, render, render, stringValuerenderAndResolve, resolve, statusint size()
@Nonnull Iterable<? extends SoyValue> keys()
Important: Iteration order is undefined.
boolean containsKey(SoyValue key)
key - The item key to check.SoyValue get(SoyValue key)
key - The item key to get.SoyValueProvider getProvider(SoyValue key)
key - The item key to get.@Nonnull Map<? extends SoyValue,? extends SoyValueProvider> asJavaMap()