public static SchemaComponent deSchema(String name, JsonNode n) { if (n.isObject()) return deSchema(name, (ObjectNode)n); if (n.isArray()) return deSchema(name, (ArrayNode)n); if (n.isBoolean()) return deSchema(name, (BooleanNode)n); if(n.isInt()) return deSchema(name, (IntNode)n); if (n.isFloatingPointNumber()) return deSchema(name, (DoubleNode)n); if (n.isNull()) return deSchema(name, (NullNode)n); return null; }
private JsonNode convertToJsonNode(AvroDefaultConfig defaultConfig) { switch (defaultConfig.avroType) { case BOOLEAN: return Boolean.parseBoolean(defaultConfig.defaultValue) ? BooleanNode.TRUE : BooleanNode.FALSE; case INTEGER: return new IntNode(Integer.parseInt(defaultConfig.defaultValue)); case LONG: return new LongNode(Long.parseLong(defaultConfig.defaultValue)); case FLOAT: // FloatNode is fairly recent and our Jackson version does not have it yet return new DoubleNode(Float.parseFloat(defaultConfig.defaultValue)); case DOUBLE: return new DoubleNode(Double.parseDouble(defaultConfig.defaultValue)); case STRING: return new TextNode(defaultConfig.defaultValue); default: throw new IllegalArgumentException("Unknown type: " + defaultConfig.avroType); } }
private Object processPrimitive(final JsonNode prim) { Object val; if (prim instanceof BooleanNode) { val = prim.getBooleanValue(); } else if (prim instanceof DoubleNode) { val = prim.getDoubleValue(); } else if (prim instanceof IntNode) { val = prim.getIntValue(); } else if (prim instanceof LongNode) { val = prim.getLongValue(); } else { val = prim.getTextValue(); } return val; }
private static SchemaComponent deSchema(String name, DoubleNode i) { NumberSC schema = new NumberSC(); return schema; }