use of com.google.template.soy.types.UnknownType in project closure-templates by google.
the class MapToLegacyObjectMapFunction method computeForJbcSrc.
@Override
public SoyExpression computeForJbcSrc(JbcSrcPluginContext context, List<SoyExpression> args) {
SoyExpression soyExpression = Iterables.getOnlyElement(args);
SoyType originalType = soyExpression.soyRuntimeType().soyType();
LegacyObjectMapType newType;
if (originalType instanceof MapType) {
newType = LegacyObjectMapType.of(((MapType) originalType).getKeyType(), ((MapType) originalType).getValueType());
} else if (originalType instanceof UnknownType) {
newType = LegacyObjectMapType.of(UnknownType.getInstance(), UnknownType.getInstance());
} else {
throw new IllegalArgumentException("mapToLegacyObjectMap() expects input to be MAP, get " + originalType.getKind());
}
return SoyExpression.forLegacyObjectMap(newType, JbcSrcMethods.MAP_TO_LEGACY_OBJECT_MAP.invoke(soyExpression.box().checkedCast(SoyMap.class)));
}
use of com.google.template.soy.types.UnknownType 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