Package com.clickhouse.client.data
Class ClickHouseEnumValue
- java.lang.Object
-
- com.clickhouse.client.data.ClickHouseEnumValue
-
- All Implemented Interfaces:
ClickHouseValue,Serializable
public class ClickHouseEnumValue extends Object implements ClickHouseValue
Wraper class of enum.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedClickHouseEnumValue(ClickHouseEnum type, boolean isNull, int value)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description BigDecimalasBigDecimal(int scale)Gets value asBigDecimal.BigIntegerasBigInteger()Gets value asBigInteger.byteasByte()Gets value as byte.doubleasDouble()Gets value as double.floatasFloat()Gets value as float.intasInteger()Gets value as integer.longasLong()Gets value as long.ObjectasObject()Gets value as an object.shortasShort()Gets value as short.StringasString(int length, Charset charset)Gets value as fixed length(in bytes) string.ClickHouseEnumValuecopy(boolean deep)Gets a copy of this value object.booleanequals(Object obj)intgetValue()Gets value.inthashCode()booleanisNullOrEmpty()Checks if the value is null, or empty for non-null types like Array, Tuple and Map.static ClickHouseEnumValueof(ClickHouseEnum type, int value)Wrap the given value.static ClickHouseEnumValueof(ClickHouseEnum type, Number value)Wrap the given value.static ClickHouseEnumValueof(ClickHouseValue ref, ClickHouseEnum type, int value)Update value of the given object or create a new instance ifrefis null.static ClickHouseEnumValueof(ClickHouseValue ref, Enum<?> value)Update value of the given object or create a new instance ifrefis null.static ClickHouseEnumValueof(Enum<?> value)Wrap the given value.static ClickHouseEnumValueofNull(ClickHouseEnum type)Create a new instance representing null value.static ClickHouseEnumValueofNull(ClickHouseValue ref, ClickHouseEnum type)Update given value to null or create a new instance ifrefis null.static ClickHouseEnumValueofNull(ClickHouseValue ref, Class<? extends Enum> clazz)Update given value to null or create a new instance ifrefis null.static ClickHouseEnumValueofNull(Class<? extends Enum> clazz)Create a new instance representing null value.ClickHouseEnumValueresetToNullOrEmpty()Resets value to null, or empty when null is not supported(e.g.protected ClickHouseEnumValueset(boolean isNull, int value)StringtoSqlExpression()Converts the value to escaped SQL expression.StringtoString()ClickHouseEnumValueupdate(byte value)Updates value.ClickHouseEnumValueupdate(char value)Updates value.ClickHouseEnumValueupdate(double value)Updates value.ClickHouseEnumValueupdate(float value)Updates value.ClickHouseEnumValueupdate(int value)Updates value.ClickHouseEnumValueupdate(long value)Updates value.ClickHouseEnumValueupdate(short value)Updates value.ClickHouseEnumValueupdate(ClickHouseValue value)Updates value.ClickHouseEnumValueupdate(Enum<?> value)Updates value.ClickHouseEnumValueupdate(Object value)Updates value.ClickHouseEnumValueupdate(String value)Updates value.ClickHouseEnumValueupdate(BigDecimal value)Updates value.ClickHouseEnumValueupdate(BigInteger value)Updates value.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.clickhouse.client.ClickHouseValue
asArray, asArray, asBigDecimal, asBoolean, asByteStream, asCharacter, asCharacterStream, asDate, asDateTime, asDateTime, asEnum, asInet4Address, asInet6Address, asInstant, asInstant, asMap, asMap, asObject, asOffsetDateTime, asOffsetDateTime, asString, asString, asString, asTime, asTime, asTuple, asUuid, asZonedDateTime, asZonedDateTime, copy, isInfinity, isNaN, newUnsupportedException, update, update, update, update, update, update, update, update, update, update, update, update, update, update, update, update, update, update, update, update, update, update, update, update, updateUnknown
-
-
-
-
Constructor Detail
-
ClickHouseEnumValue
protected ClickHouseEnumValue(ClickHouseEnum type, boolean isNull, int value)
-
-
Method Detail
-
ofNull
public static ClickHouseEnumValue ofNull(Class<? extends Enum> clazz)
Create a new instance representing null value.- Parameters:
clazz- enum class- Returns:
- new instance representing null value
-
ofNull
public static ClickHouseEnumValue ofNull(ClickHouseEnum type)
Create a new instance representing null value.- Parameters:
type- enum type, null is same asClickHouseEnum.EMPTY- Returns:
- new instance representing null value
-
ofNull
public static ClickHouseEnumValue ofNull(ClickHouseValue ref, Class<? extends Enum> clazz)
Update given value to null or create a new instance ifrefis null.- Parameters:
ref- object to update, could be nullclazz- enum class- Returns:
- same object as
refor a new instance if it's null
-
ofNull
public static ClickHouseEnumValue ofNull(ClickHouseValue ref, ClickHouseEnum type)
Update given value to null or create a new instance ifrefis null.- Parameters:
ref- object to update, could be nulltype- enum type, null is same asClickHouseEnum.EMPTY- Returns:
- same object as
refor a new instance if it's null
-
of
public static ClickHouseEnumValue of(Enum<?> value)
Wrap the given value.- Parameters:
value- value- Returns:
- object representing the value
-
of
public static ClickHouseEnumValue of(ClickHouseEnum type, int value)
Wrap the given value.- Parameters:
value- valuetype- enum type- Returns:
- object representing the value
-
of
public static ClickHouseEnumValue of(ClickHouseEnum type, Number value)
Wrap the given value.- Parameters:
value- valuetype- enum type- Returns:
- object representing the value
-
of
public static ClickHouseEnumValue of(ClickHouseValue ref, Enum<?> value)
Update value of the given object or create a new instance ifrefis null.- Parameters:
ref- object to update, could be nullvalue- value- Returns:
- same object as
refor a new instance if it's null
-
of
public static ClickHouseEnumValue of(ClickHouseValue ref, ClickHouseEnum type, int value)
Update value of the given object or create a new instance ifrefis null.- Parameters:
ref- object to update, could be nulltype- enum type, null is same asClickHouseEnum.EMPTYvalue- value- Returns:
- same object as
refor a new instance if it's null
-
set
protected ClickHouseEnumValue set(boolean isNull, int value)
-
getValue
public int getValue()
Gets value.- Returns:
- value
-
copy
public ClickHouseEnumValue copy(boolean deep)
Description copied from interface:ClickHouseValueGets a copy of this value object.- Specified by:
copyin interfaceClickHouseValue- Parameters:
deep- true to create a deep copy; false for a shallow copy- Returns:
- copy of this value object
-
isNullOrEmpty
public boolean isNullOrEmpty()
Description copied from interface:ClickHouseValueChecks 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
falsefor an empty string. This is because String is treated as value-based type instead of a container like Array.- Specified by:
isNullOrEmptyin interfaceClickHouseValue- Returns:
- true if the value is null or empty; false otherwise
-
asByte
public byte asByte()
Description copied from interface:ClickHouseValueGets value as byte.- Specified by:
asBytein interfaceClickHouseValue- Returns:
- byte value
-
asShort
public short asShort()
Description copied from interface:ClickHouseValueGets value as short.- Specified by:
asShortin interfaceClickHouseValue- Returns:
- short value
-
asInteger
public int asInteger()
Description copied from interface:ClickHouseValueGets value as integer.- Specified by:
asIntegerin interfaceClickHouseValue- Returns:
- integer value
-
asLong
public long asLong()
Description copied from interface:ClickHouseValueGets value as long.- Specified by:
asLongin interfaceClickHouseValue- Returns:
- long value
-
asBigInteger
public BigInteger asBigInteger()
Description copied from interface:ClickHouseValueGets value asBigInteger.- Specified by:
asBigIntegerin interfaceClickHouseValue- Returns:
- big integer, could be null
-
asFloat
public float asFloat()
Description copied from interface:ClickHouseValueGets value as float.- Specified by:
asFloatin interfaceClickHouseValue- Returns:
- float value
-
asDouble
public double asDouble()
Description copied from interface:ClickHouseValueGets value as double.- Specified by:
asDoublein interfaceClickHouseValue- Returns:
- double value
-
asBigDecimal
public BigDecimal asBigDecimal(int scale)
Description copied from interface:ClickHouseValueGets value asBigDecimal.- Specified by:
asBigDecimalin interfaceClickHouseValue- Parameters:
scale- scale of the decimal- Returns:
- big decimal, could be null
-
asObject
public Object asObject()
Description copied from interface:ClickHouseValueGets value as an object.- Specified by:
asObjectin interfaceClickHouseValue- Returns:
- an object representing the value, could be null
-
asString
public String asString(int length, Charset charset)
Description copied from interface:ClickHouseValueGets value as fixed length(in bytes) string.- Specified by:
asStringin interfaceClickHouseValue- Parameters:
length- byte length of the string, 0 or negative number means unboundedcharset- charset, null is same as default(UTF-8)- Returns:
- string value, could be null
-
resetToNullOrEmpty
public ClickHouseEnumValue resetToNullOrEmpty()
Description copied from interface:ClickHouseValueResets 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.
- Specified by:
resetToNullOrEmptyin interfaceClickHouseValue- Returns:
- this object
-
toSqlExpression
public String toSqlExpression()
Description copied from interface:ClickHouseValueConverts the value to escaped SQL expression. For example, number 123 will be converted to123, while string "12'3" will be converted to @{code '12\'3'}.- Specified by:
toSqlExpressionin interfaceClickHouseValue- Returns:
- escaped SQL expression
-
update
public ClickHouseEnumValue update(char value)
Description copied from interface:ClickHouseValueUpdates value.- Specified by:
updatein interfaceClickHouseValue- Parameters:
value- value to update- Returns:
- this object
-
update
public ClickHouseEnumValue update(byte value)
Description copied from interface:ClickHouseValueUpdates value.- Specified by:
updatein interfaceClickHouseValue- Parameters:
value- value to update- Returns:
- this object
-
update
public ClickHouseEnumValue update(short value)
Description copied from interface:ClickHouseValueUpdates value.- Specified by:
updatein interfaceClickHouseValue- Parameters:
value- value to update- Returns:
- this object
-
update
public ClickHouseEnumValue update(int value)
Description copied from interface:ClickHouseValueUpdates value.- Specified by:
updatein interfaceClickHouseValue- Parameters:
value- value to update- Returns:
- this object
-
update
public ClickHouseEnumValue update(long value)
Description copied from interface:ClickHouseValueUpdates value.- Specified by:
updatein interfaceClickHouseValue- Parameters:
value- value to update- Returns:
- this object
-
update
public ClickHouseEnumValue update(float value)
Description copied from interface:ClickHouseValueUpdates value.- Specified by:
updatein interfaceClickHouseValue- Parameters:
value- value to update- Returns:
- this object
-
update
public ClickHouseEnumValue update(double value)
Description copied from interface:ClickHouseValueUpdates value.- Specified by:
updatein interfaceClickHouseValue- Parameters:
value- value to update- Returns:
- this object
-
update
public ClickHouseEnumValue update(BigInteger value)
Description copied from interface:ClickHouseValueUpdates value.- Specified by:
updatein interfaceClickHouseValue- Parameters:
value- value to update- Returns:
- this object
-
update
public ClickHouseEnumValue update(BigDecimal value)
Description copied from interface:ClickHouseValueUpdates value.- Specified by:
updatein interfaceClickHouseValue- Parameters:
value- value to update- Returns:
- this object
-
update
public ClickHouseEnumValue update(Enum<?> value)
Description copied from interface:ClickHouseValueUpdates value.- Specified by:
updatein interfaceClickHouseValue- Parameters:
value- value to update- Returns:
- this object
-
update
public ClickHouseEnumValue update(String value)
Description copied from interface:ClickHouseValueUpdates value.- Specified by:
updatein interfaceClickHouseValue- Parameters:
value- value to update- Returns:
- this object
-
update
public ClickHouseEnumValue update(ClickHouseValue value)
Description copied from interface:ClickHouseValueUpdates value.- Specified by:
updatein interfaceClickHouseValue- Parameters:
value- value to update- Returns:
- this object
-
update
public ClickHouseEnumValue update(Object value)
Description copied from interface:ClickHouseValueUpdates value. This method tries to identify type ofvalueand then use corresponding update method to proceed. Unknown value will be passed toClickHouseValue.updateUnknown(Object).- Specified by:
updatein interfaceClickHouseValue- Parameters:
value- value to update, could be null- Returns:
- this object
-
-