static Field toField()

in src/main/java/com/amazon/rdsdata/client/TypeConverter.java [44:74]


    static Field toField(Object o) {
        if (o == null || o == FieldMapper.NULL) {
            return new Field().withIsNull(true);
        } else if (o instanceof Byte || o instanceof Integer || o instanceof Long) {
            return new Field().withLongValue(((Number) o).longValue());
        } else if (o instanceof Double || o instanceof Float) {
            return new Field().withDoubleValue(((Number) o).doubleValue());
        } else if (o instanceof Character) {
            return new Field().withLongValue((long) (Character) o);
        } else if (o instanceof String) {
            return new Field().withStringValue(o.toString());
        } else if (o instanceof Boolean) {
            return new Field().withBooleanValue((Boolean) o);
        } else if (o instanceof byte[]) {
            return new Field().withBlobValue(ByteBuffer.wrap((byte[]) o));
        } else if (o instanceof BigDecimal || o instanceof BigInteger) {
            return new Field().withStringValue(o.toString());
        } else if (o instanceof LocalDateTime) {
            return new Field().withStringValue(DATE_TIME_FORMATTER.format((LocalDateTime) o));
        } else if (o instanceof LocalDate) {
            return new Field().withStringValue(DATE_FORMATTER.format((LocalDate) o));
        } else if (o instanceof LocalTime) {
            return new Field().withStringValue(TIME_FORMATTER.format((LocalTime) o));
        } else if (o instanceof Enum) {
            return new Field().withStringValue(((Enum<?>) o).name());
        } else if (o instanceof UUID) {
            return new Field().withStringValue(o.toString());
        }

        throw new IllegalArgumentException(ERROR_PARAMETER_OF_UNKNOWN_TYPE + o.getClass().getName());
    }