private Expr readTypeExpr(Expr expr, ClassTemplateSpec spec) {
DataSchema.Type schemaType = spec.getSchema().getType();
Expr className = expr(spec.getClassName());
switch (schemaType) {
case ENUM:
return className.enumRead(expr);
case RECORD:
case UNION:
return className.readJSON(expr);
case MAP:
CourierMapTemplateSpec mapSpec = (CourierMapTemplateSpec)spec;
ClassTemplateSpec valueSpec = selectMapValueType(mapSpec);
return expr.mapValues(readTypeExpr($0, valueSpec, mapSpec.getCustomInfo(), false));
case ARRAY:
ArrayTemplateSpec arraySpec = (ArrayTemplateSpec)spec;
ClassTemplateSpec itemSpec = selectArrayItemsType(arraySpec);
return expr.map(readTypeExpr($0, itemSpec, arraySpec.getCustomInfo(), false));
default:
throw new IllegalArgumentException("unrecognized type: " + schemaType);
}
}