/** Combine the two maps. */ public static SoyDict augmentMap(SoyDict first, SoyDict second) { Map<String, SoyValueProvider> map = Maps.newHashMapWithExpectedSize(first.getItemCnt() + second.getItemCnt()); map.putAll(first.asJavaStringMap()); map.putAll(second.asJavaStringMap()); return DictImpl.forProviderMap(map, RuntimeType.LEGACY_OBJECT_MAP_OR_RECORD); }
public static SoyMapImpl legacyObjectMapToMap(SoyDict map) { ImmutableMap.Builder<SoyValue, SoyValueProvider> builder = ImmutableMap.builder(); for (Map.Entry<String, ? extends SoyValueProvider> entry : map.asJavaStringMap().entrySet()) { builder.put(StringData.forValue(entry.getKey()), entry.getValue()); } return SoyMapImpl.forProviderMap(builder.build()); }
return ((EnumSoyValue) data).getValue(); } else if (data instanceof SoyDict) { return new HashMap<>(Maps.transformValues(((SoyDict) data).asResolvedJavaStringMap(), new Function<SoyValue, Object>() { @Override public Object apply(SoyValue from) {
/** * Combine the two maps -- for the JavaSource variant while the function signature is still ? * instead of map. */ public static SoyDict augmentMap(SoyValue sv1, SoyValue sv2) { SoyDict first = (SoyDict) sv1; SoyDict second = (SoyDict) sv2; Map<String, SoyValueProvider> map = Maps.newHashMapWithExpectedSize(first.getItemCnt() + second.getItemCnt()); map.putAll(first.asJavaStringMap()); map.putAll(second.asJavaStringMap()); return DictImpl.forProviderMap(map, RuntimeMapTypeTracker.Type.LEGACY_OBJECT_MAP_OR_RECORD); }