private void parseProps(JsonNode json) { for (Iterator<String> i = json.fieldNames(); i.hasNext();) { String p = i.next(); // add non-reserved as props if (!PROTOCOL_RESERVED.contains(p)) this.addProp(p, json.get(p)); } }
private void parseProps(JsonNode json) { for (Iterator<String> i = json.getFieldNames(); i.hasNext();) { String p = i.next(); // add non-reserved as props if (!PROTOCOL_RESERVED.contains(p)) this.addProp(p, json.get(p)); } }
private Protocol addStringType(Protocol p) { if (stringType != StringType.String) return p; Protocol newP = new Protocol(p.getName(), p.getDoc(), p.getNamespace()); Map<Schema,Schema> types = new LinkedHashMap<>(); for (Map.Entry<String, Object> a : p.getObjectProps().entrySet()) { newP.addProp(a.getKey(), a.getValue()); } // annotate types Collection<Schema> namedTypes = new LinkedHashSet<>(); for (Schema s : p.getTypes()) namedTypes.add(addStringType(s, types)); newP.setTypes(namedTypes); // annotate messages Map<String,Message> newM = newP.getMessages(); for (Message m : p.getMessages().values()) newM.put(m.getName(), m.isOneWay() ? newP.createMessage(m, addStringType(m.getRequest(), types)) : newP.createMessage(m, addStringType(m.getRequest(), types), addStringType(m.getResponse(), types), addStringType(m.getErrors(), types))); return newP; }
@Test public void testSplitProtocolBuild() { Protocol p = new Protocol("P", null, "foo"); p.addProp("property", "some value"); String protocolString = p.toString(); final int mid = protocolString.length() / 2; String[] parts = { protocolString.substring(0, mid), protocolString.substring(mid), }; Protocol parsedStringProtocol = org.apache.avro.Protocol.parse(protocolString); Protocol parsedArrayOfStringProtocol = org.apache.avro.Protocol.parse(protocolString.substring(0, mid), protocolString.substring(mid)); assertNotNull(parsedStringProtocol); assertNotNull(parsedArrayOfStringProtocol); assertEquals(parsedStringProtocol.toString(), parsedArrayOfStringProtocol.toString()); } }
private void parseProps(JsonNode json) { for (Iterator<String> i = json.getFieldNames(); i.hasNext();) { String p = i.next(); // add non-reserved as props if (!PROTOCOL_RESERVED.contains(p)) this.addProp(p, json.get(p)); } }
private void parseProps(JsonNode json) { for (Iterator<String> i = json.getFieldNames(); i.hasNext();) { String p = i.next(); // add non-reserved as props if (!PROTOCOL_RESERVED.contains(p)) this.addProp(p, json.get(p)); } }