/** * Converts a value object for an expected JDBC type of {@link Types#SMALLINT}. * * @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 convertSmallInt(Column column, Field fieldDefn, Object data) { return convertValue(column, fieldDefn, data, SHORT_FALSE, (r) -> { if (data instanceof Short) { r.deliver(data); } else if (data instanceof Number) { Number value = (Number) data; r.deliver(Short.valueOf(value.shortValue())); } else if (data instanceof Boolean) { r.deliver(NumberConversions.getShort((Boolean)data)); } else if (data instanceof String) { r.deliver(Short.valueOf((String)data)); } }); }
/** * Converts a value object for an expected JDBC type of {@link Types#SMALLINT}. * * @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 convertSmallInt(Column column, Field fieldDefn, Object data) { return convertValue(column, fieldDefn, data, SHORT_FALSE, (r) -> { if (data instanceof Short) { r.deliver(data); } else if (data instanceof Number) { Number value = (Number) data; r.deliver(new Short(value.shortValue())); } else if (data instanceof Boolean) { r.deliver(NumberConversions.getShort((Boolean)data)); } else if (data instanceof String) { r.deliver(Short.parseShort((String)data)); } }); }