public final NullNode nullNode() { return _nodeFactory.nullNode(); }
/** * Alternate factory method that will handle wrapper value, which may * be null. * Due to possibility of null, returning type is not guaranteed to be * {@link NumericNode}, but just {@link ValueNode}. * * @since 1.9 */ public ValueNode numberNode(Long value) { return (value == null) ? nullNode() : LongNode.valueOf(value.longValue()); }
/** * Alternate factory method that will handle wrapper value, which may * be null. * Due to possibility of null, returning type is not guaranteed to be * {@link NumericNode}, but just {@link ValueNode}. * * @since 1.9 */ public ValueNode numberNode(Float value) { return (value == null) ? nullNode() : DoubleNode.valueOf(value.doubleValue()); }
/** * Alternate factory method that will handle wrapper value, which may * be null. * Due to possibility of null, returning type is not guaranteed to be * {@link NumericNode}, but just {@link ValueNode}. * * @since 1.9 */ public ValueNode numberNode(Short value) { return (value == null) ? nullNode() : IntNode.valueOf(value.shortValue()); }
/** * Alternate factory method that will handle wrapper value, which may * be null. * Due to possibility of null, returning type is not guaranteed to be * {@link NumericNode}, but just {@link ValueNode}. * * @since 1.9 */ public ValueNode numberNode(Double value) { return (value == null) ? nullNode() : DoubleNode.valueOf(value.doubleValue()); }
/** * Alternate factory method that will handle wrapper value, which may * be null. * Due to possibility of null, returning type is not guaranteed to be * {@link NumericNode}, but just {@link ValueNode}. * * @since 1.9 */ public ValueNode numberNode(Byte value) { return (value == null) ? nullNode() : IntNode.valueOf(value.intValue()); }
/** * Alternate factory method that will handle wrapper value, which may * be null. * Due to possibility of null, returning type is not guaranteed to be * {@link NumericNode}, but just {@link ValueNode}. * * @since 1.9 */ public ValueNode numberNode(Integer value) { return (value == null) ? nullNode() : IntNode.valueOf(value.intValue()); }
private List<Schema.Field> getFields(Schema.Field schemaField) { List<Schema.Field> fields = new ArrayList<Schema.Field>(); JsonNode nullDefault = JsonNodeFactory.instance.nullNode(); if (schemaField.schema().getType() == Schema.Type.RECORD) { for (Schema.Field field : schemaField.schema().getFields()) { fields.add(new Schema.Field(field.name(), field.schema(), field.doc(), nullDefault)); } } else { fields.add(new Schema.Field(schemaField.name(), schemaField.schema(), schemaField.doc(), nullDefault)); } return fields; }
private Schema buildRecordSchema(JsonSchema schema, WorkUnitState workUnit, String name, String namespace) { List<Schema.Field> fields = new ArrayList<>(); for (int i = 0; i < schema.fieldsCount(); i++) { JsonSchema map = schema.getFieldSchemaAt(i); String childNamespace = buildNamespace(namespace, name); JsonElementConverter converter; String sourceType; Schema fldSchema; try { sourceType = map.isType(UNION) ? UNION.toString().toLowerCase() : map.getType().toString().toLowerCase(); converter = getConvertor(map, childNamespace, workUnit); this.converters.put(map.getColumnName(), converter); fldSchema = converter.schema(); } catch (UnsupportedDateTypeException e) { throw new UnsupportedOperationException(e); } Schema.Field fld = new Schema.Field(map.getColumnName(), fldSchema, map.getComment(), map.isNullable() ? JsonNodeFactory.instance.nullNode() : null); fld.addProp(SOURCE_TYPE, sourceType); fields.add(fld); } Schema avroSchema = Schema.createRecord(name.isEmpty() ? null : name, "", namespace, false); avroSchema.setFields(fields); return avroSchema; }
/** * Customized {@link TypeResolverBuilder} that provides type resolver builders * used with so-called "default typing" * (see {@link ObjectMapper#enableDefaultTyping()} for details). *<p> * Type resolver construction is based on configuration: implementation takes care * of only providing builders in cases where type information should be applied. * This is important since build calls may be sent for any and all types, and * type information should NOT be applied to all of them. */ public static class DefaultTypeResolverBuilder extends StdTypeResolverBuilder { /** * Definition of what types is this default typer valid for. */ protected final DefaultTyping _appliesFor; public DefaultTypeResolverBuilder(DefaultTyping t) { _appliesFor = t; } @Override public TypeDeserializer buildTypeDeserializer(DeserializationConfig config, JavaType baseType, Collection<NamedType> subtypes, BeanProperty property) { return useForType(baseType) ? super.buildTypeDeserializer(config, baseType, subtypes, property) : null; } @Override
public final NullNode nullNode() { return _nodeFactory.nullNode(); }
/** * Alternate factory method that will handle wrapper value, which may * be null. * Due to possibility of null, returning type is not guaranteed to be * {@link NumericNode}, but just {@link ValueNode}. * * @since 1.9 */ public ValueNode numberNode(Short value) { return (value == null) ? nullNode() : IntNode.valueOf(value.shortValue()); }
/** * Alternate factory method that will handle wrapper value, which may * be null. * Due to possibility of null, returning type is not guaranteed to be * {@link NumericNode}, but just {@link ValueNode}. * * @since 1.9 */ public ValueNode numberNode(Double value) { return (value == null) ? nullNode() : DoubleNode.valueOf(value.doubleValue()); }
/** * Alternate factory method that will handle wrapper value, which may * be null. * Due to possibility of null, returning type is not guaranteed to be * {@link NumericNode}, but just {@link ValueNode}. * * @since 1.9 */ public ValueNode numberNode(Long value) { return (value == null) ? nullNode() : LongNode.valueOf(value.longValue()); }
/** * Alternate factory method that will handle wrapper value, which may * be null. * Due to possibility of null, returning type is not guaranteed to be * {@link NumericNode}, but just {@link ValueNode}. * * @since 1.9 */ public ValueNode numberNode(Byte value) { return (value == null) ? nullNode() : IntNode.valueOf(value.intValue()); }
/** * Alternate factory method that will handle wrapper value, which may * be null. * Due to possibility of null, returning type is not guaranteed to be * {@link NumericNode}, but just {@link ValueNode}. * * @since 1.9 */ public ValueNode numberNode(Integer value) { return (value == null) ? nullNode() : IntNode.valueOf(value.intValue()); }
/** * Alternate factory method that will handle wrapper value, which may * be null. * Due to possibility of null, returning type is not guaranteed to be * {@link NumericNode}, but just {@link ValueNode}. * * @since 1.9 */ public ValueNode numberNode(Float value) { return (value == null) ? nullNode() : DoubleNode.valueOf(value.doubleValue()); }
/** * Customized {@link TypeResolverBuilder} that provides type resolver builders * used with so-called "default typing" * (see {@link ObjectMapper#enableDefaultTyping()} for details). *<p> * Type resolver construction is based on configuration: implementation takes care * of only providing builders in cases where type information should be applied. * This is important since build calls may be sent for any and all types, and * type information should NOT be applied to all of them. */ public static class DefaultTypeResolverBuilder extends StdTypeResolverBuilder { /** * Definition of what types is this default typer valid for. */ protected final DefaultTyping _appliesFor; public DefaultTypeResolverBuilder(DefaultTyping t) { _appliesFor = t; } @Override public TypeDeserializer buildTypeDeserializer(DeserializationConfig config, JavaType baseType, Collection<NamedType> subtypes, BeanProperty property) { return useForType(baseType) ? super.buildTypeDeserializer(config, baseType, subtypes, property) : null; } @Override