static Object fromField()

in src/main/java/com/amazon/rdsdata/client/TypeConverter.java [93:133]


    static Object fromField(Field field, Class<?> type) {
        // TODO: Class comparison by == (or .equals) may not work if classes belong to different classloaders
        if (field.isNull() != null && field.isNull()) {
            return null;
        } if (type == String.class) {
            return field.getStringValue();
        } else if (type == Byte.class || type == byte.class) {
            return field.getLongValue().byteValue();
        } else if (type == Integer.class || type == int.class) {
            return field.getLongValue().intValue();
        } else if (type == Long.class || type == long.class) {
            return field.getLongValue();
        } else if (type == Character.class || type == char.class) {
            return (char) field.getLongValue().longValue();
        } else if (type == Double.class || type == double.class) {
            return field.getDoubleValue();
        } else if (type == Float.class || type == float.class) {
            return field.getDoubleValue().floatValue();
        } else if (type == byte[].class) {
            return field.getBlobValue().array();
        } else if (type == Boolean.class || type == boolean.class) {
            return field.getBooleanValue();
        } else if (type == BigDecimal.class) {
            return toBigDecimal(field);
        } else if (type == BigInteger.class) {
            return toBigInteger(field);
        } else if (Enum.class.isAssignableFrom(type)) {
            return Enum.valueOf((Class<? extends Enum>) type, field.getStringValue());
        } else if (type == UUID.class) {
            return java.util.UUID.fromString(field.getStringValue());
        } else if (type == LocalDateTime.class) {
            return LocalDateTime.from(DATE_TIME_FORMATTER.parse(field.getStringValue()));
        } else if (type == LocalDate.class) {
            return dateFromString(field.getStringValue());
        } else if (type == LocalTime.class) {
            return timeFromString(field.getStringValue());
        }

        // TODO: handle this case
        return null;
    }