/** * Converts a value object for an expected JDBC type of {@link Types#INTEGER}. * * @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 convertInteger(Column column, Field fieldDefn, Object data) { return convertValue(column, fieldDefn, data, 0, (r) -> { if (data instanceof Integer) { r.deliver(data); } else if (data instanceof Number) { Number value = (Number) data; r.deliver(Integer.valueOf(value.intValue())); } else if (data instanceof Boolean) { r.deliver(NumberConversions.getInteger((Boolean)data)); } else if (data instanceof String) { r.deliver(Integer.valueOf((String)data)); } }); }
/** * Converts a value object for an expected JDBC type of {@link Types#INTEGER}. * * @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 convertInteger(Column column, Field fieldDefn, Object data) { return convertValue(column, fieldDefn, data, 0, (r) -> { if (data instanceof Integer) { r.deliver(data); } else if (data instanceof Number) { Number value = (Number) data; r.deliver(Integer.valueOf(value.intValue())); } else if (data instanceof Boolean) { r.deliver(NumberConversions.getInteger((Boolean)data)); } else if (data instanceof String) { r.deliver(Integer.parseInt((String)data)); } }); }