org.codehaus.jackson.node.LongNode Java Examples
The following examples show how to use
org.codehaus.jackson.node.LongNode.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AvroSchemaGenerator.java From datacollector with Apache License 2.0 | 6 votes |
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); } }
Example #2
Source File: GenericEntityDeserializer.java From secure-data-service with Apache License 2.0 | 6 votes |
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; }
Example #3
Source File: CSVUtils.java From localization_nifi with Apache License 2.0 | 4 votes |
/** * */ private static void updateRecord(Field field, Type type, String providedValue, Record avroRecord) { if (Type.NULL != type) { Object value; if (Type.INT == type) { value = null == providedValue ? possiblyGetDefaultValue(field, IntNode.class).getIntValue() : Integer.parseInt(providedValue); avroRecord.put(field.name(), value); } else if (Type.BOOLEAN == type) { value = null == providedValue ? possiblyGetDefaultValue(field, BooleanNode.class).getBooleanValue() : Boolean.parseBoolean(providedValue); avroRecord.put(field.name(), value); } else if (Type.DOUBLE == type) { value = null == providedValue ? possiblyGetDefaultValue(field, DoubleNode.class).getDoubleValue() : Double.parseDouble(providedValue); avroRecord.put(field.name(), value); } else if (Type.FLOAT == type) { value = null == providedValue ? possiblyGetDefaultValue(field, DoubleNode.class).getDoubleValue() : Float.parseFloat(providedValue); avroRecord.put(field.name(), value); } else if (Type.LONG == type) { value = null == providedValue ? possiblyGetDefaultValue(field, LongNode.class).getLongValue() : Long.parseLong(providedValue); avroRecord.put(field.name(), value); } else if (Type.STRING == type) { value = null == providedValue ? possiblyGetDefaultValue(field, TextNode.class).getTextValue() : providedValue; avroRecord.put(field.name(), value); } else if (Type.BYTES == type) { value = encodeLogicalType(field, providedValue); avroRecord.put(field.name(), value); } else if (Type.UNION == type) { field.schema().getTypes() .forEach(schema -> updateRecord(field, schema.getType(), providedValue, avroRecord)); } else if (Type.ARRAY == type || Type.ENUM == type || Type.FIXED == type || Type.MAP == type || Type.NULL == type || Type.RECORD == type) { throw new IllegalArgumentException("The field type '" + type + "' is not supported at the moment"); } else { avroRecord.put(field.name(), providedValue); } } }