/** * Given an expression that evaluates to a Swift data binding type, and it's pegasus type, * return an expression that evaluates to the corresponding SwiftyJson JSON type. * * @param expr provides the expression that evaluates to a SwiftyJson JSON type. * @param spec provides the pegasus type that the returned expression should toSwiftCode to. */ private Expr writeTypeExpr(Expr expr, ClassTemplateSpec spec, CustomInfoSpec customInfo) { if (customInfo != null) { Expr coercer = expr(customInfo.getCoercerClass().getClassName()); return coercer.coercerOutput(writeTypeExpr(expr, spec)); } else { return writeTypeExpr(expr, spec); } }
DataSchema refSchema = customInfo.getCustomSchema().getDereferencedDataSchema(); fieldType = ClassTemplateSpec.createFromDataSchema(refSchema); String coercer = customInfo.getCoercerClass().getClassName(); String uncoerced = toLiteral(fieldType.getSchema(), field.getSchemaField().getDefault()); if (uncoerced == null) {
Expr coercer = expr(custom.getCoercerClass().getClassName()); if (isOptional) { return directAccessor.map(coercer.coercerInput($0)); Expr coercer = expr(custom.getCoercerClass().getClassName()); if (isOptional) { return directAccessor.map(coercer.coercerInput(readTypeExpr($0, spec)));
CustomInfoSpec customInfo = mapSpec.getCustomInfo(); if (customInfo != null) { Expr coercer = expr(customInfo.getCoercerClass().getClassName()); return expr.mapValues(writeTypeExpr(coercer.coercerOutput($0), valueSpec)); } else { CustomInfoSpec arrayCustomInfo = arraySpec.getCustomInfo(); if (arrayCustomInfo != null) { Expr coercer = expr(arrayCustomInfo.getCoercerClass().getClassName()); return expr.map(writeTypeExpr(coercer.coercerOutput($0), itemSpec)); } else {