@Test void bigDecimalsInArrays(final JsonBuilderFactory jsonBuilderFactory, final JsonProvider jsonProvider, final RecordBuilderFactory recordBuilderFactory, final RecordConverters converter) throws Exception { final BigDecimal pos1 = new BigDecimal("48.8480275637"); final BigDecimal pos2 = new BigDecimal("2.25369456784"); final BigDecimal pos3 = new BigDecimal(25); final List<BigDecimal> expected = asList(pos1, pos2, pos1, pos2, pos2, pos1, pos3); try (final Jsonb jsonb = JsonbBuilder.create()) { final JsonObject json = jsonBuilderFactory .createObjectBuilder() .add("coordinates", jsonBuilderFactory .createArrayBuilder() .add(jsonBuilderFactory.createArrayBuilder().add(pos1).add(pos2).build()) .add(jsonBuilderFactory.createArrayBuilder().add(pos1).add(pos2).build()) .add(jsonBuilderFactory.createArrayBuilder().add(pos2).add(pos1).add(pos3).build()) .build()) .build(); final Record record = converter.toRecord(new MappingMetaRegistry(), json, () -> jsonb, () -> recordBuilderFactory); assertEquals(expected, record .getArray(ArrayList.class, "coordinates") .stream() .flatMap(a -> a.stream()) .flatMap(bd -> Stream.of(bd)) .collect(toList())); } }
public <T> Record toRecord(final MappingMetaRegistry registry, final T data, final Supplier<Jsonb> jsonbProvider, final Supplier<RecordBuilderFactory> recordBuilderProvider) { if (data == null) { return null; } if (Record.class.isInstance(data)) { return Record.class.cast(data); } if (JsonObject.class.isInstance(data)) { return json2Record(recordBuilderProvider.get(), JsonObject.class.cast(data)); } final MappingMeta meta = registry.find(data.getClass()); if (meta.isLinearMapping()) { return meta.newRecord(data, recordBuilderProvider.get()); } final Jsonb jsonb = jsonbProvider.get(); if (!String.class.isInstance(data) && !data.getClass().isPrimitive() && PojoJsonbProvider.class.isInstance(jsonb)) { final Jsonb pojoMapper = PojoJsonbProvider.class.cast(jsonb).get(); final OutputRecordHolder holder = new OutputRecordHolder(); try (final OutputRecordHolder stream = holder) { pojoMapper.toJson(data, stream); } return holder.getRecord(); } return json2Record(recordBuilderProvider.get(), jsonb.fromJson(jsonb.toJson(data), JsonObject.class)); }
RecordConverters implements Serializable { public <T> Record toRecord(final MappingMetaRegistry registry, final T data, final Supplier<Jsonb> jsonbProvider, final Supplier<RecordBuilderFactory> recordBuilderProvider) { if (data == null) { return null; } if (Record.class.isInstance(data)) { return Record.class.cast(data); } if (JsonObject.class.isInstance(data)) { return json2Record(recordBuilderProvider.get(), JsonObject.class.cast(data)); } final MappingMeta meta = registry.find(data.getClass()); if (meta.isLinearMapping()) { return meta.newRecord(data, recordBuilderProvider.get()); } final Jsonb jsonb = jsonbProvider.get(); if (!String.class.isInstance(data) && !data.getClass().isPrimitive() && PojoJsonbProvider.class.isInstance(jsonb)) { final Jsonb pojoMapper = PojoJsonbProvider.class.cast(jsonb).get(); final OutputRecordHolder holder = new OutputRecordHolder(); try (final OutputRecordHolder stream = holder) { pojoMapper.toJson(data, stream); } return holder.getRecord(); } return json2Record(recordBuilderProvider.get(), jsonb.fromJson(jsonb.toJson(data), JsonObject.class)); } }
RecordConverters implements Serializable { public <T> Record toRecord(final MappingMetaRegistry registry, final T data, final Supplier<Jsonb> jsonbProvider, final Supplier<RecordBuilderFactory> recordBuilderProvider) { if (data == null) { return null; } if (Record.class.isInstance(data)) { return Record.class.cast(data); } if (JsonObject.class.isInstance(data)) { return json2Record(recordBuilderProvider.get(), JsonObject.class.cast(data)); } final MappingMeta meta = registry.find(data.getClass()); if (meta.isLinearMapping()) { return meta.newRecord(data, recordBuilderProvider.get()); } final Jsonb jsonb = jsonbProvider.get(); if (!String.class.isInstance(data) && !data.getClass().isPrimitive() && PojoJsonbProvider.class.isInstance(jsonb)) { final Jsonb pojoMapper = PojoJsonbProvider.class.cast(jsonb).get(); final OutputRecordHolder holder = new OutputRecordHolder(); try (final OutputRecordHolder stream = holder) { pojoMapper.toJson(data, stream); } return holder.getRecord(); } return json2Record(recordBuilderProvider.get(), jsonb.fromJson(jsonb.toJson(data), JsonObject.class)); }  }
RecordConverters implements Serializable { public <T> Record toRecord(final MappingMetaRegistry registry, final T data, final Supplier<Jsonb> jsonbProvider, final Supplier<RecordBuilderFactory> recordBuilderProvider) { if (data == null) { return null; } if (Record.class.isInstance(data)) { return Record.class.cast(data); } if (JsonObject.class.isInstance(data)) { return json2Record(recordBuilderProvider.get(), JsonObject.class.cast(data)); } final MappingMeta meta = registry.find(data.getClass()); if (meta.isLinearMapping()) { return meta.newRecord(data, recordBuilderProvider.get()); } final Jsonb jsonb = jsonbProvider.get(); if (!String.class.isInstance(data) && !data.getClass().isPrimitive() && PojoJsonbProvider.class.isInstance(jsonb)) { final Jsonb pojoMapper = PojoJsonbProvider.class.cast(jsonb).get(); final OutputRecordHolder holder = new OutputRecordHolder(); try (final OutputRecordHolder stream = holder) { pojoMapper.toJson(data, stream); } return holder.getRecord(); } return json2Record(recordBuilderProvider.get(), jsonb.fromJson(jsonb.toJson(data), JsonObject.class)); }  T mapNumber(final Class<T> expected, final Number from); Record toRecord(final MappingMetaRegistry registry, final T data, final Supplier<Jsonb> jsonbProvider,
            final Supplier<RecordBuilderFactory> recordBuilderProvider); static Schema toSchema(final RecordBuilderFactory factory, final Object next); Object toType(final MappingMetaRegistry registry, final Object data, final Class<?> parameterType,
            final Supplier<JsonBuilderFactory> factorySupplier, final Supplier<JsonProvider> providerSupplier,
            final Supplier<Jsonb> jsonbProvider, final Supplier<RecordBuilderFactory> recordBuilderProvider); Object toType(final MappingMetaRegistry registry, final Object data, final Class<?> parameterType,
            final Supplier<JsonBuilderFactory> factorySupplier, final Supplier<JsonProvider> providerSupplier,
            final Supplier<Jsonb> jsonbProvider, final Supplier<RecordBuilderFactory> recordBuilderProvider,
            final java.util.Map<String, String> metadata); T coerce(final Class<T> expectedType, final Object value, final String name); }
RecordConverters implements Serializable { public <T> Record toRecord(final MappingMetaRegistry registry, final T data, final Supplier<Jsonb> jsonbProvider, final Supplier<RecordBuilderFactory> recordBuilderProvider) { if (data == null) { return null; } if (Record.class.isInstance(data)) { return Record.class.cast(data); } if (JsonObject.class.isInstance(data)) { return json2Record(recordBuilderProvider.get(), JsonObject.class.cast(data)); } final MappingMeta meta = registry.find(data.getClass()); if (meta.isLinearMapping()) { return meta.newRecord(data, recordBuilderProvider.get()); } final Jsonb jsonb = jsonbProvider.get(); if (!String.class.isInstance(data) && !data.getClass().isPrimitive() && PojoJsonbProvider.class.isInstance(jsonb)) { final Jsonb pojoMapper = PojoJsonbProvider.class.cast(jsonb).get(); final OutputRecordHolder holder = new OutputRecordHolder(); try (final OutputRecordHolder stream = holder) { pojoMapper.toJson(data, stream); } return holder.getRecord(); } return json2Record(recordBuilderProvider.get(), jsonb.fromJson(jsonb.toJson(data), JsonObject.class)); }  T mapNumber(final Class<T> expected, final Number from); Record toRecord(final MappingMetaRegistry registry, final T data, final Supplier<Jsonb> jsonbProvider,
            final Supplier<RecordBuilderFactory> recordBuilderProvider); static Schema toSchema(final RecordBuilderFactory factory, final Object next); Object toType(final MappingMetaRegistry registry, final Object data, final Class<?> parameterType,
            final Supplier<JsonBuilderFactory> factorySupplier, final Supplier<JsonProvider> providerSupplier,
            final Supplier<Jsonb> jsonbProvider, final Supplier<RecordBuilderFactory> recordBuilderProvider); Object toType(final MappingMetaRegistry registry, final Object data, final Class<?> parameterType,
            final Supplier<JsonBuilderFactory> factorySupplier, final Supplier<JsonProvider> providerSupplier,
            final Supplier<Jsonb> jsonbProvider, final Supplier<RecordBuilderFactory> recordBuilderProvider,
            final java.util.Map<String, String> metadata); T coerce(final Class<T> expectedType, final Object value, final String name);  }