Interface ClickHouseValue

    • Method Detail

      • newUnsupportedException

        default UnsupportedOperationException newUnsupportedException​(String from,
                                                                      String to)
        Create a customized exception for unsupported type conversion.
        Parameters:
        from - type to convert from
        to - type to convert to
        Returns:
        customized exception
      • copy

        default ClickHouseValue copy()
        Gets a shallow copy of this value object. Same as copy(false).
        Returns:
        shallow copy of this value object
      • copy

        ClickHouseValue copy​(boolean deep)
        Gets a copy of this value object.
        Parameters:
        deep - true to create a deep copy; false for a shallow copy
        Returns:
        copy of this value object
      • isInfinity

        default boolean isInfinity()
        Checks if the value is either positive or negative infinity as defined in Double.
        Returns:
        true if it's infinity; false otherwise
      • isNaN

        default boolean isNaN()
        Checks if the value is Not-a-Number (NaN).
        Returns:
        true if the value is NaN; false otherwise
      • isNullOrEmpty

        boolean isNullOrEmpty()
        Checks if the value is null, or empty for non-null types like Array, Tuple and Map.

        Please pay attention that only nullability will be considered for String, meaning this method will return false for an empty string. This is because String is treated as value-based type instead of a container like Array.

        Returns:
        true if the value is null or empty; false otherwise
      • asArray

        default Object[] asArray()
        Gets value as an object array.
        Returns:
        non-null object array
      • asArray

        default <T> T[] asArray​(Class<T> clazz)
        Gets value as an array.
        Type Parameters:
        T - type of the element
        Parameters:
        clazz - class of the element
        Returns:
        non-null array
      • asByteStream

        default InputStream asByteStream()
        Gets value as byte stream. It's caller's responsibility to close the stream at the end of reading.
        Returns:
        non-null byte stream for reading
      • asCharacterStream

        default Reader asCharacterStream()
        Gets value as character stream. It's caller's responsibility to close the tream at the end of reading.
        Returns:
        non-null character stream for reading
      • asBoolean

        default boolean asBoolean()
        Gets value as boolean.
        Returns:
        boolean value
      • asCharacter

        default char asCharacter()
        Gets value as character.
        Returns:
        character value
      • asByte

        byte asByte()
        Gets value as byte.
        Returns:
        byte value
      • asShort

        short asShort()
        Gets value as short.
        Returns:
        short value
      • asInteger

        int asInteger()
        Gets value as integer.
        Returns:
        integer value
      • asLong

        long asLong()
        Gets value as long.
        Returns:
        long value
      • asBigInteger

        BigInteger asBigInteger()
        Gets value as BigInteger.
        Returns:
        big integer, could be null
      • asFloat

        float asFloat()
        Gets value as float.
        Returns:
        float value
      • asDouble

        double asDouble()
        Gets value as double.
        Returns:
        double value
      • asBigDecimal

        default BigDecimal asBigDecimal()
        Gets value as BigDecimal, using default scale(usually 0).
        Returns:
        big decimal, could be null
      • asBigDecimal

        BigDecimal asBigDecimal​(int scale)
        Gets value as BigDecimal.
        Parameters:
        scale - scale of the decimal
        Returns:
        big decimal, could be null
      • asDate

        default LocalDate asDate()
        Gets value as LocalDate.
        Returns:
        date, could be null
      • asTime

        default LocalTime asTime()
        Gets value as LocalTime.
        Returns:
        time, could be null
      • asTime

        default LocalTime asTime​(int scale)
        Gets value as LocalTime.
        Parameters:
        scale - scale of the date time, between 0 (second) and 9 (nano second)
        Returns:
        time, could be null
      • asDateTime

        default LocalDateTime asDateTime()
        Gets value as LocalDateTime, using default scale(usually 0).
        Returns:
        date time, could be null
      • asInstant

        default Instant asInstant()
        Gets value as Instant, using default scale(usually 0).
        Returns:
        date time, could be null
      • asOffsetDateTime

        default OffsetDateTime asOffsetDateTime()
        Gets value as OffsetDateTime, using default scale(usually 0).
        Returns:
        date time, could be null
      • asZonedDateTime

        default ZonedDateTime asZonedDateTime()
        Gets value as ZonedDateTime, using default scale(usually 0).
        Returns:
        date time, could be null
      • asDateTime

        default LocalDateTime asDateTime​(int scale)
        Gets value as LocalDateTime.
        Parameters:
        scale - scale of the date time, between 0 (second) and 9 (nano second)
        Returns:
        date time, could be null
      • asInstant

        default Instant asInstant​(int scale)
        Gets value as Instant.
        Parameters:
        scale - scale of the date time, between 0 (second) and 9 (nano second)
        Returns:
        instant, could be null
      • asOffsetDateTime

        default OffsetDateTime asOffsetDateTime​(int scale)
        Gets value as OffsetDateTime.
        Parameters:
        scale - scale of the date time, between 0 (second) and 9 (nano second)
        Returns:
        date time, could be null
      • asZonedDateTime

        default ZonedDateTime asZonedDateTime​(int scale)
        Gets value as ZonedDateTime.
        Parameters:
        scale - scale of the date time, between 0 (second) and 9 (nano second)
        Returns:
        date time, could be null
      • asEnum

        default <T extends Enum<T>> T asEnum​(Class<T> enumType)
        Gets value as enum.
        Type Parameters:
        T - type of the enum
        Parameters:
        enumType - enum class
        Returns:
        enum, could be null
      • asInet4Address

        default Inet4Address asInet4Address()
        Gets value as Inet4Address.
        Returns:
        IPv4 address, could be null
      • asInet6Address

        default Inet6Address asInet6Address()
        Gets value as Inet6Address.
        Returns:
        IPv6 address, could be null
      • asMap

        default Map<Object,​Object> asMap()
        Gets value as a map.
        Returns:
        non-null map value
      • asMap

        default <K,​V> Map<K,​V> asMap​(Class<K> keyClass,
                                                 Class<V> valueClass)
        Gets value as a map.
        Type Parameters:
        K - type of key
        V - type of value
        Parameters:
        keyClass - non-null class of key
        valueClass - non-null class of value
        Returns:
        non-null map value
      • asObject

        Object asObject()
        Gets value as an object.
        Returns:
        an object representing the value, could be null
      • asObject

        default <T,​E extends Enum<E>> T asObject​(Class<T> clazz)
        Gets value as a typed object.
        Type Parameters:
        T - type of the object
        E - type of the enum
        Parameters:
        clazz - class of the object
        Returns:
        a typed object representing the value, could be null
      • asBinary

        default byte[] asBinary()
        Gets binary value as byte array.
        Returns:
        byte array which could be null
      • asBinary

        default byte[] asBinary​(int length)
        Gets binary value as fixed length byte array.
        Parameters:
        length - byte length of value, 0 or negative number means no limit
        Returns:
        byte array which could be null
      • asBinary

        default byte[] asBinary​(Charset charset)
        Gets binary value as byte array.
        Parameters:
        charset - charset, null is same as default(UTF-8)
        Returns:
        byte array which could be null
      • asBinary

        default byte[] asBinary​(int length,
                                Charset charset)
        Gets binary value as byte array.
        Parameters:
        length - byte length of value, 0 or negative number means no limit
        charset - charset, null is same as default(UTF-8)
        Returns:
        byte array which could be null
      • asString

        default String asString()
        Gets value as unbounded string, using default charset(usually UTF-8).
        Returns:
        string value, could be null
      • asString

        default String asString​(int length)
        Gets value as fixed length(in bytes) string, using default charset(usually UTF-8).
        Parameters:
        length - byte length of the string, 0 or negative number means unbounded
        Returns:
        string value, could be null
      • asString

        default String asString​(Charset charset)
        Gets value as unbounded string.
        Parameters:
        charset - charset, null is same as default(UTF-8)
        Returns:
        string value, could be null
      • asString

        default String asString​(int length,
                                Charset charset)
        Gets value as fixed length(in bytes) string.
        Parameters:
        length - byte length of the string, 0 or negative number means unbounded
        charset - charset, null is same as default(UTF-8)
        Returns:
        string value, could be null
      • asTuple

        default List<Object> asTuple()
        Gets value as ordered list(tuple).
        Returns:
        non-null list
      • asUuid

        default UUID asUuid()
        Gets value as UUID.
        Returns:
        uuid, could be null
      • resetToNullOrEmpty

        ClickHouseValue resetToNullOrEmpty()
        Resets value to null, or empty when null is not supported(e.g. Array, Tuple and Map etc.).

        Keep in mind that String is value-based type, so this method will change its value to null instead of an empty string.

        Returns:
        this object
      • toSqlExpression

        String toSqlExpression()
        Converts the value to escaped SQL expression. For example, number 123 will be converted to 123, while string "12'3" will be converted to @{code '12\'3'}.
        Returns:
        escaped SQL expression
      • update

        default ClickHouseValue update​(InputStream value)
        Updates value.
        Parameters:
        value - value to update
        Returns:
        this object
      • update

        default ClickHouseValue update​(Reader value)
        Updates value.
        Parameters:
        value - value to update
        Returns:
        this object
      • update

        default ClickHouseValue update​(boolean value)
        Updates value.
        Parameters:
        value - value to update
        Returns:
        this object
      • update

        default ClickHouseValue update​(boolean[] value)
        Updates value.
        Parameters:
        value - value to update
        Returns:
        this object
      • update

        default ClickHouseValue update​(char value)
        Updates value.
        Parameters:
        value - value to update
        Returns:
        this object
      • update

        default ClickHouseValue update​(char[] value)
        Updates value.
        Parameters:
        value - value to update
        Returns:
        this object
      • update

        ClickHouseValue update​(byte value)
        Updates value.
        Parameters:
        value - value to update
        Returns:
        this object
      • update

        default ClickHouseValue update​(byte[] value)
        Updates value.
        Parameters:
        value - value to update
        Returns:
        this object
      • update

        ClickHouseValue update​(short value)
        Updates value.
        Parameters:
        value - value to update
        Returns:
        this object
      • update

        default ClickHouseValue update​(short[] value)
        Updates value.
        Parameters:
        value - value to update
        Returns:
        this object
      • update

        ClickHouseValue update​(int value)
        Updates value.
        Parameters:
        value - value to update
        Returns:
        this object
      • update

        default ClickHouseValue update​(int[] value)
        Updates value.
        Parameters:
        value - value to update
        Returns:
        this object
      • update

        ClickHouseValue update​(long value)
        Updates value.
        Parameters:
        value - value to update
        Returns:
        this object
      • update

        default ClickHouseValue update​(long[] value)
        Updates value.
        Parameters:
        value - value to update
        Returns:
        this object
      • update

        ClickHouseValue update​(float value)
        Updates value.
        Parameters:
        value - value to update
        Returns:
        this object
      • update

        default ClickHouseValue update​(float[] value)
        Updates value.
        Parameters:
        value - value to update
        Returns:
        this object
      • update

        ClickHouseValue update​(double value)
        Updates value.
        Parameters:
        value - value to update
        Returns:
        this object
      • update

        default ClickHouseValue update​(double[] value)
        Updates value.
        Parameters:
        value - value to update
        Returns:
        this object
      • update

        ClickHouseValue update​(BigInteger value)
        Updates value.
        Parameters:
        value - value to update
        Returns:
        this object
      • update

        ClickHouseValue update​(BigDecimal value)
        Updates value.
        Parameters:
        value - value to update
        Returns:
        this object
      • update

        default ClickHouseValue update​(Enum<?> value)
        Updates value.
        Parameters:
        value - value to update
        Returns:
        this object
      • update

        default ClickHouseValue update​(Inet4Address value)
        Updates value.
        Parameters:
        value - value to update
        Returns:
        this object
      • update

        default ClickHouseValue update​(Inet6Address value)
        Updates value.
        Parameters:
        value - value to update
        Returns:
        this object
      • update

        default ClickHouseValue update​(LocalDate value)
        Updates value.
        Parameters:
        value - value to update
        Returns:
        this object
      • update

        default ClickHouseValue update​(LocalTime value)
        Updates value.
        Parameters:
        value - value to update
        Returns:
        this object
      • update

        default ClickHouseValue update​(Instant value)
        Updates value.
        Parameters:
        value - value to update
        Returns:
        this object
      • update

        default ClickHouseValue update​(Collection<?> value)
        Updates value.
        Parameters:
        value - value to update
        Returns:
        this object
      • update

        default ClickHouseValue update​(Enumeration<?> value)
        Updates value.
        Parameters:
        value - value to update
        Returns:
        this object
      • update

        default ClickHouseValue update​(Map<?,​?> value)
        Updates value.
        Parameters:
        value - value to update
        Returns:
        this object
      • update

        ClickHouseValue update​(String value)
        Updates value.
        Parameters:
        value - value to update
        Returns:
        this object
      • update

        default ClickHouseValue update​(UUID value)
        Updates value.
        Parameters:
        value - value to update
        Returns:
        this object
      • update

        default ClickHouseValue update​(Object[] value)
        Updates value.
        Parameters:
        value - value to update
        Returns:
        this object
      • updateUnknown

        default ClickHouseValue updateUnknown​(Object value)
        Updates value when the type is not supported. This method will be called at the end of update(Object) after trying all known classes. By default, it's same as update(String.valueOf(value)).

        Please avoid to call update(Object) here as it will create endless loop.

        Parameters:
        value - value to update
        Returns:
        this object
      • update

        default ClickHouseValue update​(Object value)
        Updates value. This method tries to identify type of value and then use corresponding update method to proceed. Unknown value will be passed to updateUnknown(Object).
        Parameters:
        value - value to update, could be null
        Returns:
        this object