@Override public String renderSchemaEntry(SchemaEntry schemaEntry, boolean requestForLatest) { return requestForLatest ? schemaEntry.toString() : schemaEntry.getSchema(); }
@Override public String renderSchemaEntry(SchemaEntry schemaEntry, boolean requestForLatest) { return requestForLatest ? schemaEntry.toString() : schemaEntry.getSchema(); }
/** * Encode {@link SchemaEntry} objects into a {@link String} for use by * {@link #schemasFromString(String)} * * @param allEntries * the SchemaEntry objects to encode * @return The {@link SchemaEntry} objects encoded as a String */ public static String schemasToString(Iterable<SchemaEntry> allEntries) { StringBuilder sb = new StringBuilder(); boolean scheamWithNewLine = false; for (SchemaEntry s : allEntries) { if (s.getSchema().contains("\n")) { scheamWithNewLine = true; } sb.append(s.toString()).append("\n"); } if (scheamWithNewLine) { return new StringBuilder() .append(MessageStrings.SCHEMA_WITH_NEWLINE_ERROR) .append(sb).toString(); } else { return sb.toString(); } }
/** * Encode {@link SchemaEntry} objects into a {@link String} for use by * {@link #schemasFromString(String)} * * @param allEntries * the SchemaEntry objects to encode * @return The {@link SchemaEntry} objects encoded as a String */ public static String schemasToString(Iterable<SchemaEntry> allEntries) { StringBuilder sb = new StringBuilder(); boolean scheamWithNewLine = false; for (SchemaEntry s : allEntries) { if (s.getSchema().contains("\n")) { scheamWithNewLine = true; } sb.append(s.toString()).append("\n"); } if (scheamWithNewLine) { return new StringBuilder() .append(MessageStrings.SCHEMA_WITH_NEWLINE_ERROR) .append(sb).toString(); } else { return sb.toString(); } }
@Test public void testToString() { SchemaEntry entry = new SchemaEntry("id", "schema"); SchemaEntry toAndFrom = new SchemaEntry(entry.toString()); Assert.assertEquals(entry, toAndFrom); }