/** * Converts a value object for an expected JDBC type of {@link Types#DOUBLE}. * * @param column the column definition describing the {@code data} value; never null * @param fieldDefn the field definition; never null * @param data the data object to be converted into a {@link Date Kafka Connect date} type; never null * @return the converted value, or null if the conversion could not be made and the column allows nulls * @throws IllegalArgumentException if the value could not be converted but the column does not allow nulls */ protected Object convertDouble(Column column, Field fieldDefn, Object data) { return convertValue(column, fieldDefn, data, 0.0d, (r) -> { if (data instanceof Double) { r.deliver(data); } else if (data instanceof Number) { // Includes BigDecimal and other numeric values ... Number value = (Number) data; r.deliver(Double.valueOf(value.doubleValue())); } else if (data instanceof SpecialValueDecimal) { r.deliver(((SpecialValueDecimal)data).toDouble()); } else if (data instanceof Boolean) { r.deliver(NumberConversions.getDouble((Boolean) data)); } }); }
/** * Converts a value object for an expected JDBC type of {@link Types#DOUBLE}. * * @param column the column definition describing the {@code data} value; never null * @param fieldDefn the field definition; never null * @param data the data object to be converted into a {@link Date Kafka Connect date} type; never null * @return the converted value, or null if the conversion could not be made and the column allows nulls * @throws IllegalArgumentException if the value could not be converted but the column does not allow nulls */ protected Object convertDouble(Column column, Field fieldDefn, Object data) { return convertValue(column, fieldDefn, data, 0.0d, (r) -> { if (data instanceof Double) { r.deliver(data); } else if (data instanceof Number) { // Includes BigDecimal and other numeric values ... Number value = (Number) data; r.deliver(Double.valueOf(value.doubleValue())); } else if (data instanceof SpecialValueDecimal) { r.deliver(((SpecialValueDecimal)data).toDouble()); } else if (data instanceof Boolean) { r.deliver(NumberConversions.getDouble((Boolean) data)); } }); }