use of com.google.template.soy.types.SoyType in project closure-templates by google.
the class LegacyObjectMapToMapFunction method computeForJbcSrc.
@Override
public SoyExpression computeForJbcSrc(JbcSrcPluginContext context, List<SoyExpression> args) {
SoyExpression soyExpression = Iterables.getOnlyElement(args);
SoyType originalType = soyExpression.soyRuntimeType().soyType();
MapType newType;
if (originalType instanceof LegacyObjectMapType) {
newType = MapType.of(((LegacyObjectMapType) originalType).getKeyType(), ((LegacyObjectMapType) originalType).getValueType());
} else if (originalType instanceof UnknownType) {
newType = MapType.of(UnknownType.getInstance(), UnknownType.getInstance());
} else {
throw new IllegalArgumentException("legacyObjectMapToMap() expects input to be LEGACY_OBJECT_MAP, get " + originalType.getKind());
}
return SoyExpression.forMap(newType, JbcSrcMethods.LEGACY_OBJECT_MAP_TO_MAP.invoke(soyExpression.box().checkedCast(SoyDict.class)));
}
Aggregations