private ClassTemplateSpec getDereferencedType(CustomInfoSpec customInfo, ClassTemplateSpec fallback) { if (customInfo != null) { DataSchema refSchema = customInfo.getCustomSchema().getDereferencedDataSchema(); return ClassTemplateSpec.createFromDataSchema(refSchema); } else { return fallback; } }
private CustomInfoSpec getImmediateCustomInfo(DataSchema schema) { if (_immediateCustomMap.containsKey(schema)) { return _immediateCustomMap.get(schema); } CustomInfoSpec immediate = null; for (DataSchema current = schema; current != null; current = dereferenceIfTyperef(current)) { final CustomClasses customClasses = getCustomClasses(current); if (customClasses != null) { immediate = new CustomInfoSpec((NamedDataSchema) schema, (NamedDataSchema) current, customClasses.customClass, customClasses.customCoercerClass); break; } } // immediate may be null _immediateCustomMap.put(schema, immediate); return immediate; }
ClassTemplateSpec fieldType; if (customInfo != null) { 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) {
/** * 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); } }
result = customInfo.getCustomClass(); result = (customInfo != null) ? customInfo.getCustomClass() : getPrimitiveClassForSchema((PrimitiveDataSchema) schema, enclosingClass, memberName);
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)));
private ClassAndSchema getMapValueName(MapDataSchema mapSchema, ClassTemplateSpec enclosingClass, String memberName) { CustomInfoSpec customInfo = getImmediateCustomInfo(mapSchema.getValues()); if (customInfo != null) { return new ClassAndSchema(new ClassInfo(customInfo.getCustomSchema().getNamespace(), customInfo.getCustomSchema().getName()), customInfo.getCustomSchema()); } else { return new ClassAndSchema(classNameForUnnamedTraverse(enclosingClass, memberName, mapSchema.getValues()), mapSchema.getValues()); } }
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 {
public static CustomInfoSpec getImmediateCustomInfo(DataSchema schema, String customTypeLanguage) { CustomInfoSpec immediate = null; for (DataSchema current = schema; current != null; current = dereferenceIfTyperef(current)) { final CourierTemplateSpecGenerator.CustomClasses customClasses = CourierTemplateSpecGenerator.getCustomClasses(current, customTypeLanguage); if (customClasses != null) { immediate = new CustomInfoSpec( (NamedDataSchema) schema, (NamedDataSchema) current, customClasses.customClass, customClasses.customCoercerClass); break; } } return immediate; }
NamedDataSchema customSchema = keyCustomInfo.getCustomSchema(); return new ClassAndSchema(new ClassInfo(customSchema.getNamespace(), customSchema.getName()), customSchema);
if (customInfo != null) return new ClassInfo(customInfo.getCustomSchema().getNamespace(), customInfo.getCustomSchema().getName() + ARRAY_SUFFIX);