BigDecimalToDoubleConverter implements Converter<Double, BigDecimal> { @Override public Result<BigDecimal> convertToModel(Double value, ValueContext context) { if (value == null) { return Result.ok(null); } return Result.ok(BigDecimal.valueOf(value)); }  @Override Result<BigDecimal> convertToModel(Double value, ValueContext context); @Override Double convertToPresentation(BigDecimal value, ValueContext context);  }
@Test public void testConvertToModel() { BigDecimalToDoubleConverter converter = new BigDecimalToDoubleConverter(); assertNull(converter.convertToModel(null, createContext()).getOrThrow(r -> new OCSRuntimeException())); Result<BigDecimal> bd = converter.convertToModel(1.2, createContext()); assertEquals(1.2, bd.getOrThrow(r -> new OCSRuntimeException()).doubleValue(), 0.001); }