Package com.clickhouse.client.data
Class ClickHouseMapValue
- java.lang.Object
-
- com.clickhouse.client.data.ClickHouseObjectValue<Map<?,?>>
-
- com.clickhouse.client.data.ClickHouseMapValue
-
- All Implemented Interfaces:
ClickHouseValue,Serializable
public class ClickHouseMapValue extends ClickHouseObjectValue<Map<?,?>>
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedClickHouseMapValue(Map<?,?> value, Class<?> keyType, Class<?> valueType)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Map<Object,Object>asMap()Gets value as a map.<K,V>
Map<K,V>asMap(Class<K> keyClass, Class<V> valueClass)Gets value as a map.StringasString(int length, Charset charset)Gets value as fixed length(in bytes) string.ClickHouseMapValuecopy(boolean deep)Gets a copy of this value object.protected ObjectgetDefaultKey()booleanisNullOrEmpty()Checks if the value is null, or empty for non-null types like Array, Tuple and Map.static ClickHouseMapValueof(ClickHouseValue ref, Map<?,?> value, Class<?> keyType, Class<?> valueType)Update value of the given object or create a new instance ifrefis null.static ClickHouseMapValueof(Map<?,?> value, Class<?> keyType, Class<?> valueType)Wrap the given value.static ClickHouseMapValueofEmpty(Class<?> keyType, Class<?> valueType)Creates an empty map.ClickHouseMapValueresetToNullOrEmpty()Resets value to null, or empty when null is not supported(e.g.protected ClickHouseMapValueset(Map<?,?> value)StringtoSqlExpression()Converts the value to escaped SQL expression.ClickHouseMapValueupdate(byte value)Updates value.ClickHouseMapValueupdate(double value)Updates value.ClickHouseMapValueupdate(float value)Updates value.ClickHouseMapValueupdate(int value)Updates value.ClickHouseMapValueupdate(long value)Updates value.ClickHouseMapValueupdate(short value)Updates value.ClickHouseMapValueupdate(ClickHouseValue value)Updates value.ClickHouseMapValueupdate(Enum<?> value)Updates value.ClickHouseValueupdate(Object value)Updates value.ClickHouseMapValueupdate(String value)Updates value.ClickHouseMapValueupdate(BigDecimal value)Updates value.ClickHouseMapValueupdate(BigInteger value)Updates value.ClickHouseMapValueupdate(Inet4Address value)Updates value.ClickHouseMapValueupdate(Inet6Address value)Updates value.ClickHouseMapValueupdate(LocalDate value)Updates value.ClickHouseMapValueupdate(LocalDateTime value)Updates value.ClickHouseMapValueupdate(LocalTime value)Updates value.ClickHouseMapValueupdate(Map<?,?> value)Updates value.ClickHouseMapValueupdate(UUID value)Updates value.ClickHouseValueupdateUnknown(Object value)Updates value when the type is not supported.-
Methods inherited from class com.clickhouse.client.data.ClickHouseObjectValue
asBigDecimal, asBigInteger, asByte, asDouble, asFloat, asInteger, asLong, asObject, asShort, equals, getValue, hashCode, toString
-
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, 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
-
-
-
-
Method Detail
-
ofEmpty
public static ClickHouseMapValue ofEmpty(Class<?> keyType, Class<?> valueType)
Creates an empty map.- Parameters:
keyType- non-null class of keyvalueType- non-null class of value- Returns:
- empty map
-
of
public static ClickHouseMapValue of(Map<?,?> value, Class<?> keyType, Class<?> valueType)
Wrap the given value.- Parameters:
value- valuekeyType- non-null class of keyvalueType- non-null class of value- Returns:
- object representing the value
-
of
public static ClickHouseMapValue of(ClickHouseValue ref, Map<?,?> value, Class<?> keyType, Class<?> valueType)
Update value of the given object or create a new instance ifrefis null.- Parameters:
ref- object to update, could be nullvalue- valuekeyType- non-null class of keyvalueType- non-null class of value- Returns:
- same object as
refor a new instance if it's null
-
getDefaultKey
protected Object getDefaultKey()
-
set
protected ClickHouseMapValue set(Map<?,?> value)
- Overrides:
setin classClickHouseObjectValue<Map<?,?>>
-
copy
public ClickHouseMapValue copy(boolean deep)
Description copied from interface:ClickHouseValueGets 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
-
asMap
public Map<Object,Object> asMap()
Description copied from interface:ClickHouseValueGets value as a map.- Returns:
- non-null map value
-
asMap
public <K,V> Map<K,V> asMap(Class<K> keyClass, Class<V> valueClass)
Description copied from interface:ClickHouseValueGets value as a map.- Type Parameters:
K- type of keyV- type of value- Parameters:
keyClass- non-null class of keyvalueClass- non-null class of value- Returns:
- non-null map value
-
asString
public String asString(int length, Charset charset)
Description copied from interface:ClickHouseValueGets value as fixed length(in bytes) string.- Specified by:
asStringin interfaceClickHouseValue- Overrides:
asStringin classClickHouseObjectValue<Map<?,?>>- 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
-
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- Overrides:
isNullOrEmptyin classClickHouseObjectValue<Map<?,?>>- Returns:
- true if the value is null or empty; false otherwise
-
resetToNullOrEmpty
public ClickHouseMapValue 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- Overrides:
resetToNullOrEmptyin classClickHouseObjectValue<Map<?,?>>- 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- Overrides:
toSqlExpressionin classClickHouseObjectValue<Map<?,?>>- Returns:
- escaped SQL expression
-
update
public ClickHouseMapValue update(byte value)
Description copied from interface:ClickHouseValueUpdates value.- Parameters:
value- value to update- Returns:
- this object
-
update
public ClickHouseMapValue update(short value)
Description copied from interface:ClickHouseValueUpdates value.- Parameters:
value- value to update- Returns:
- this object
-
update
public ClickHouseMapValue update(int value)
Description copied from interface:ClickHouseValueUpdates value.- Parameters:
value- value to update- Returns:
- this object
-
update
public ClickHouseMapValue update(long value)
Description copied from interface:ClickHouseValueUpdates value.- Parameters:
value- value to update- Returns:
- this object
-
update
public ClickHouseMapValue update(float value)
Description copied from interface:ClickHouseValueUpdates value.- Parameters:
value- value to update- Returns:
- this object
-
update
public ClickHouseMapValue update(double value)
Description copied from interface:ClickHouseValueUpdates value.- Parameters:
value- value to update- Returns:
- this object
-
update
public ClickHouseMapValue update(BigInteger value)
Description copied from interface:ClickHouseValueUpdates value.- Parameters:
value- value to update- Returns:
- this object
-
update
public ClickHouseMapValue update(BigDecimal value)
Description copied from interface:ClickHouseValueUpdates value.- Parameters:
value- value to update- Returns:
- this object
-
update
public ClickHouseMapValue update(String value)
Description copied from interface:ClickHouseValueUpdates value.- Parameters:
value- value to update- Returns:
- this object
-
update
public ClickHouseMapValue update(Enum<?> value)
Description copied from interface:ClickHouseValueUpdates value.- Parameters:
value- value to update- Returns:
- this object
-
update
public ClickHouseMapValue update(Inet4Address value)
Description copied from interface:ClickHouseValueUpdates value.- Parameters:
value- value to update- Returns:
- this object
-
update
public ClickHouseMapValue update(Inet6Address value)
Description copied from interface:ClickHouseValueUpdates value.- Parameters:
value- value to update- Returns:
- this object
-
update
public ClickHouseMapValue update(LocalDate value)
Description copied from interface:ClickHouseValueUpdates value.- Parameters:
value- value to update- Returns:
- this object
-
update
public ClickHouseMapValue update(LocalTime value)
Description copied from interface:ClickHouseValueUpdates value.- Parameters:
value- value to update- Returns:
- this object
-
update
public ClickHouseMapValue update(LocalDateTime value)
Description copied from interface:ClickHouseValueUpdates value.- Parameters:
value- value to update- Returns:
- this object
-
update
public ClickHouseMapValue update(Map<?,?> value)
Description copied from interface:ClickHouseValueUpdates value.- Parameters:
value- value to update- Returns:
- this object
-
update
public ClickHouseMapValue update(UUID value)
Description copied from interface:ClickHouseValueUpdates value.- Parameters:
value- value to update- Returns:
- this object
-
updateUnknown
public ClickHouseValue updateUnknown(Object value)
Description copied from interface:ClickHouseValueUpdates value when the type is not supported. This method will be called at the end ofClickHouseValue.update(Object)after trying all known classes. By default, it's same asupdate(String.valueOf(value)).Please avoid to call
ClickHouseValue.update(Object)here as it will create endless loop.- Parameters:
value- value to update- Returns:
- this object
-
update
public ClickHouseMapValue update(ClickHouseValue value)
Description copied from interface:ClickHouseValueUpdates value.- Parameters:
value- value to update- Returns:
- this object
-
update
public ClickHouseValue 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- Overrides:
updatein classClickHouseObjectValue<Map<?,?>>- Parameters:
value- value to update, could be null- Returns:
- this object
-
-