private void writeTyperef(TyperefDataSchema schema) throws IOException { writeDoc(schema.getDoc()); writeProperties(schema.getProperties()); write("typeref "); write(toTypeIdentifier(schema)); write(" = "); DataSchema ref = schema.getRef(); writeReferenceOrInline(ref, schema.isRefDeclaredInline()); }
hasPackageOverride = !StringUtils.isEmpty(namedSchema.getPackage()) && !namedSchema.getPackage().equals(surroundingPackage); if (hasNamespaceOverride || hasPackageOverride) { write("{"); newline(); _indentDepth++; write("namespace "); write(namedSchema.getNamespace()); newline(); indent(); write("package "); write(namedSchema.getPackage()); newline(); indent(); break; case NULL: write("null"); break; default: newline(); indent(); write("}"); _namespace = surroundingNamespace; _package = surroundingPackage;
/** * Write a documentation string to .pdl code. * The documentation string will be embedded in a properly indented javadoc style doc string delimiters and margin. * @param doc provides the documentation to write. */ private boolean writeDoc(String doc) throws IOException { if (StringUtils.isNotBlank(doc)) { writeLine("/**"); for (String line : doc.split("\n")) { indent(); write(" * "); write(line); newline(); } writeLine(" */"); return true; } return false; }
write(toTypeIdentifier((NamedDataSchema) dataSchema));
private void writePrimitive(PrimitiveDataSchema schema) throws IOException { write(schema.getUnionMemberKey()); }
indent(); write("record "); write(toTypeIdentifier(schema)); List<NamedDataSchema> includes = schema.getInclude(); if (includes.size() > 0 && !schema.isFieldsBeforeIncludes()) write(" {"); newline(); write("@order = \""); write(field.getOrder().name()); write("\""); write("@aliases = ["); write(field.getAliases().stream().map(s -> "\"" + s + "\"").collect(Collectors.joining(", "))); write("]"); write(escapeIdentifier(field.getName())); write(": "); if (field.getOptional()) write("optional "); write(" = "); write(toJson(field.getDefault())); write("}");
private void writeIncludes(RecordDataSchema schema, List<NamedDataSchema> includes) throws IOException { write(" includes "); for (Iterator<NamedDataSchema> iter = includes.iterator(); iter.hasNext();) { NamedDataSchema include = iter.next(); writeReferenceOrInline(include, schema.isIncludeDeclaredInline(include)); if (iter.hasNext()) { write(", "); } } }
/** * Write a property string to this encoder's writer. * @param path provides the property's full path. * @param value provides the property's value, it may be any valid pegasus Data binding type (DataList, DataMap, * String, Int, Long, Float, Double, Boolean, ByteArray) */ private void writeProperty(List<String> path, Object value) throws IOException { indent(); write("@"); write(pathToString(path)); write(" = "); write(toJson(value)); newline(); }
/** * Write an intended line of .pdl code. * The code will be prefixed by the current indentation and suffixed with a newline. * @param code provide the line of .pdl code. */ private void writeLine(String code) throws IOException { indent(); write(code); newline(); }
private void writeUnion(UnionDataSchema schema) throws IOException { write("union["); for(Iterator<UnionDataSchema.Member> iter = schema.getMembers().iterator(); iter.hasNext();) { UnionDataSchema.Member member = iter.next(); writeReferenceOrInline(member.getType(), member.isDeclaredInline()); if (iter.hasNext()) { write(", "); } } write("]"); }