public interface SettableByNameData<T extends SettableData<T>>
Modifier and Type | Method and Description |
---|---|
<V> T |
set(String name,
V v,
Class<V> targetClass)
Sets the value for (all occurrences of) variable
name to the provided value of the provided Java class. |
<V> T |
set(String name,
V v,
TypeCodec<V> codec)
Sets the value for (all occurrences of) variable
name to the provided value,
converted using the given TypeCodec . |
<V> T |
set(String name,
V v,
com.google.common.reflect.TypeToken<V> targetType)
Sets the value for (all occurrences of) variable
name to the provided value of the provided Java type. |
T |
setBool(String name,
boolean v)
Sets the value for (all occurrences of) variable
name to the
provided boolean. |
T |
setByte(String name,
byte v)
Sets the value for (all occurrences of) variable
name to the
provided byte. |
T |
setBytes(String name,
ByteBuffer v)
Sets the value for (all occurrences of) variable
name to the
provided byte buffer. |
T |
setBytesUnsafe(String name,
ByteBuffer v)
Sets the value for (all occurrences of) variable
name to the
provided byte buffer. |
T |
setDate(String name,
LocalDate v)
Sets the value for (all occurrences of) variable
name to the
provided date (without time). |
T |
setDecimal(String name,
BigDecimal v)
Sets the value for (all occurrences of) variable
name to the
provided big decimal. |
T |
setDouble(String name,
double v)
Sets the value for (all occurrences of) variable
name to the
provided double. |
T |
setFloat(String name,
float v)
Sets the value for (all occurrences of) variable
name to the
provided float. |
T |
setInet(String name,
InetAddress v)
Sets the value for (all occurrences of) variable
name to the
provided inet address. |
T |
setInt(String name,
int v)
Sets the value for (all occurrences of) variable
name to the
provided integer. |
<E> T |
setList(String name,
List<E> v)
Sets the value for (all occurrences of) variable
name to the
provided list. |
<E> T |
setList(String name,
List<E> v,
Class<E> elementsClass)
Sets the value for (all occurrences of) variable
name to the provided list,
whose elements are of the provided Java class. |
<E> T |
setList(String name,
List<E> v,
com.google.common.reflect.TypeToken<E> elementsType)
Sets the value for (all occurrences of) variable
name to the provided list,
whose elements are of the provided Java type. |
T |
setLong(String name,
long v)
Sets the value for (all occurrences of) variable
name to the
provided long. |
<K,V> T |
setMap(String name,
Map<K,V> v)
Sets the value for (all occurrences of) variable
name to the
provided map. |
<K,V> T |
setMap(String name,
Map<K,V> v,
Class<K> keysClass,
Class<V> valuesClass)
Sets the value for (all occurrences of) variable
name to the provided map,
whose keys and values are of the provided Java classes. |
<K,V> T |
setMap(String name,
Map<K,V> v,
com.google.common.reflect.TypeToken<K> keysType,
com.google.common.reflect.TypeToken<V> valuesType)
Sets the value for (all occurrences of) variable
name to the provided map,
whose keys and values are of the provided Java types. |
<V> T |
setObject(String name,
V v)
Sets the value for (all occurrences of) variable
name to the provided value. |
<E> T |
setSet(String name,
Set<E> v)
Sets the value for (all occurrences of) variable
name to the
provided set. |
<E> T |
setSet(String name,
Set<E> v,
Class<E> elementsClass)
Sets the value for (all occurrences of) variable
name to the provided set,
whose elements are of the provided Java class. |
<E> T |
setSet(String name,
Set<E> v,
com.google.common.reflect.TypeToken<E> elementsType)
Sets the value for (all occurrences of) variable
name to the provided set,
whose elements are of the provided Java type. |
T |
setShort(String name,
short v)
Sets the value for (all occurrences of) variable
name to the
provided short. |
T |
setString(String name,
String v)
Sets the value for (all occurrences of) variable
name to the
provided string. |
T |
setTime(String name,
long v)
Sets the value for (all occurrences of) variable
name to the
provided time as a long in nanoseconds since midnight. |
T |
setTimestamp(String name,
Date v)
Sets the value for (all occurrences of) variable
name to the
provided date. |
T |
setToNull(String name)
Sets the value for (all occurrences of) variable
name to null . |
T |
setTupleValue(String name,
TupleValue v)
Sets the value for (all occurrences of) variable
name to the
provided tuple value. |
T |
setUDTValue(String name,
UDTValue v)
Sets the value for (all occurrences of) variable
name to the
provided UDT value. |
T |
setUUID(String name,
UUID v)
Sets the value for (all occurrences of) variable
name to the
provided UUID. |
T |
setVarint(String name,
BigInteger v)
Sets the value for (all occurrences of) variable
name to the
provided big integer. |
T setBool(String name, boolean v)
name
to the
provided boolean.name
- the name of the value to set; if name
is present multiple
times, all its values are set.v
- the value to set.IllegalArgumentException
- if name
is not a valid name for this object.InvalidTypeException
- if (any one occurrence of) name
is not of type BOOLEAN.T setByte(String name, byte v)
name
to the
provided byte.name
- the name of the value to set; if name
is present multiple
times, all its values are set.v
- the value to set.IllegalArgumentException
- if name
is not a valid name for this object.InvalidTypeException
- if (any one occurrence of) name
is not of type TINYINT.T setShort(String name, short v)
name
to the
provided short.name
- the name of the value to set; if name
is present multiple
times, all its values are set.v
- the value to set.IllegalArgumentException
- if name
is not a valid name for this object.InvalidTypeException
- if (any one occurrence of) name
is not of type SMALLINT.T setInt(String name, int v)
name
to the
provided integer.name
- the name of the value to set; if name
is present multiple
times, all its values are set.v
- the value to set.IllegalArgumentException
- if name
is not a valid name for this object.InvalidTypeException
- if (any one occurrence of) name
is not of type INT.T setLong(String name, long v)
name
to the
provided long.name
- the name of the value to set; if name
is present multiple
times, all its values are set.v
- the value to set.IllegalArgumentException
- if name
is not a valid name for this object.InvalidTypeException
- if (any occurrence of) name
is
not of type BIGINT or COUNTER.T setTimestamp(String name, Date v)
name
to the
provided date.name
- the name of the value to set; if name
is present multiple
times, all its values are set.v
- the value to set.IllegalArgumentException
- if name
is not a valid name for this object.InvalidTypeException
- if (any occurrence of) name
is
not of type TIMESTAMP.T setDate(String name, LocalDate v)
name
to the
provided date (without time).name
- the name of the value to set; if name
is present multiple
times, all its values are set.v
- the value to set.IllegalArgumentException
- if name
is not a valid name for this object.InvalidTypeException
- if (any occurrence of) name
is
not of type DATE.T setTime(String name, long v)
name
to the
provided time as a long in nanoseconds since midnight.name
- the name of the value to set; if name
is present multiple
times, all its values are set.v
- the value to set.IllegalArgumentException
- if name
is not a valid name for this object.InvalidTypeException
- if (any occurrence of) name
is
not of type TIME.T setFloat(String name, float v)
name
to the
provided float.name
- the name of the value to set; if name
is present multiple
times, all its values are set.v
- the value to set.IllegalArgumentException
- if name
is not a valid name for this object.InvalidTypeException
- if (any occurrence of) name
is
not of type FLOAT.T setDouble(String name, double v)
name
to the
provided double.name
- the name of the value to set; if name
is present multiple
times, all its values are set.v
- the value to set.IllegalArgumentException
- if name
is not a valid name for this object.InvalidTypeException
- if (any occurrence of) name
is
not of type DOUBLE.T setString(String name, String v)
name
to the
provided string.name
- the name of the value to set; if name
is present multiple
times, all its values are set.v
- the value to set.IllegalArgumentException
- if name
is not a valid name for this object.InvalidTypeException
- if (any occurrence of) name
is
of neither of the following types: VARCHAR, TEXT or ASCII.T setBytes(String name, ByteBuffer v)
name
to the
provided byte buffer.
This method validate that the type of the column set is BLOB. If you
want to insert manually serialized data into columns of another type,
use setBytesUnsafe(java.lang.String, java.nio.ByteBuffer)
instead.name
- the name of the value to set; if name
is present multiple
times, all its values are set.v
- the value to set.IllegalArgumentException
- if name
is not a valid name for this object.InvalidTypeException
- if (any occurrence of) name
is not of type BLOB.T setBytesUnsafe(String name, ByteBuffer v)
name
to the
provided byte buffer.
Contrary to setBytes(java.lang.String, java.nio.ByteBuffer)
, this method does not check the
type of the column set. If you insert data that is not compatible with
the type of the column, you will get an InvalidQueryException
at
execute time.name
- the name of the value to set; if name
is present multiple
times, all its values are set.v
- the value to set.IllegalArgumentException
- if name
is not a valid name for this object.T setVarint(String name, BigInteger v)
name
to the
provided big integer.name
- the name of the value to set; if name
is present multiple
times, all its values are set.v
- the value to set.IllegalArgumentException
- if name
is not a valid name for this object.InvalidTypeException
- if (any occurrence of) name
is
not of type VARINT.T setDecimal(String name, BigDecimal v)
name
to the
provided big decimal.name
- the name of the value to set; if name
is present multiple
times, all its values are set.v
- the value to set.IllegalArgumentException
- if name
is not a valid name for this object.InvalidTypeException
- if (any occurrence of) name
is
not of type DECIMAL.T setUUID(String name, UUID v)
name
to the
provided UUID.name
- the name of the value to set; if name
is present multiple
times, all its values are set.v
- the value to set.IllegalArgumentException
- if name
is not a valid name for this object.InvalidTypeException
- if (any occurrence of) name
is
not of type UUID or TIMEUUID, or if value name
is of type
TIMEUUID but v
is not a type 1 UUID.T setInet(String name, InetAddress v)
name
to the
provided inet address.name
- the name of the value to set; if name
is present multiple
times, all its values are set.v
- the value to set.IllegalArgumentException
- if name
is not a valid name for this object.InvalidTypeException
- if (any occurrence of) name
is
not of type INET.<E> T setList(String name, List<E> v)
name
to the
provided list.
Please note that null
values inside collections are not supported by CQL.
Note about performance: this method must perform a runtime inspection of the provided list, in order to guess the best codec to serialize the list elements. The result of such inspection cannot be cached and thus must be performed for each invocation of this method, which may incur in a performance penalty.
Furthermore, if two or more codecs are available
for the underlying CQL type (list
), which one will be used will depend
on the actual object being serialized.
For these reasons, it is generally preferable to use the more
deterministic methods setList(String, List, Class)
or
setList(String, List, TypeToken)
.
name
- the name of the value to set; if name
is present multiple
times, all its values are set.v
- the value to set.IllegalArgumentException
- if name
is not a valid name for this object.InvalidTypeException
- if (any occurrence of) name
is
not a list type or if the elements of v
are not of the type of
the elements of column name
.NullPointerException
- if v
contains null values. Nulls are not supported in collections
by CQL.<E> T setList(String name, List<E> v, Class<E> elementsClass)
name
to the provided list,
whose elements are of the provided Java class.
Please note that null
values inside collections are not supported by CQL.
Note about performance: this method is able to cache codecs used to serialize the list elements,
and thus should be used instead of setList(String, List)
whenever possible, because it performs significantly better.
name
- the name of the value to set; if name
is present multiplev
- the value to set.elementsClass
- the class for the elements of the list.IndexOutOfBoundsException
- if i
is not a valid index for this object.InvalidTypeException
- if value i
is not a list type or
if the elements of v
are not of the type of the elements of
column i
.NullPointerException
- if v
contains null values. Nulls are not supported in collections
by CQL.<E> T setList(String name, List<E> v, com.google.common.reflect.TypeToken<E> elementsType)
name
to the provided list,
whose elements are of the provided Java type.
Please note that null
values inside collections are not supported by CQL.
Note about performance: this method is able to cache codecs used to serialize the list elements,
and thus should be used instead of setList(String, List)
whenever possible, because it performs significantly better.
name
- the name of the value to set; if name
is present multiplev
- the value to set.elementsType
- the type for the elements of the list.IndexOutOfBoundsException
- if i
is not a valid index for this object.InvalidTypeException
- if value i
is not a list type or
if the elements of v
are not of the type of the elements of
column i
.NullPointerException
- if v
contains null values. Nulls are not supported in collections
by CQL.<K,V> T setMap(String name, Map<K,V> v)
name
to the
provided map.
Please note that null
values are not supported inside collection by CQL.
Note about performance: this method must perform a runtime inspection of the provided map, in order to guess the best codec to serialize the map entries. The result of such inspection cannot be cached and thus must be performed for each invocation of this method, which may incur in a performance penalty.
Furthermore, if two or more codecs are available
for the underlying CQL type (map
), which one will be used will depend
on the actual object being serialized.
For these reasons, it is generally preferable to use the more
deterministic methods setMap(String, Map, Class, Class)
or
setMap(String, Map, TypeToken, TypeToken)
.
name
- the name of the value to set; if name
is present multiple
times, all its values are set.v
- the value to set.IllegalArgumentException
- if name
is not a valid name for this object.InvalidTypeException
- if (any occurrence of) name
is
not a map type or if the elements (keys or values) of v
are not of
the type of the elements of column name
.NullPointerException
- if v
contains null values. Nulls are not supported in collections
by CQL.<K,V> T setMap(String name, Map<K,V> v, Class<K> keysClass, Class<V> valuesClass)
name
to the provided map,
whose keys and values are of the provided Java classes.
Please note that null
values inside collections are not supported by CQL.
Note about performance: this method is able to cache codecs used to serialize the map entries,
and thus should be used instead of setMap(String, Map)
whenever possible, because it performs significantly better.
name
- the name of the value to set; if name
is present multiple
times, all its values are set.v
- the value to set.keysClass
- the class for the keys of the map.valuesClass
- the class for the values of the map.IllegalArgumentException
- if name
is not a valid name for this object.InvalidTypeException
- if (any occurrence of) name
is
not a map type or if the elements (keys or values) of v
are not of
the type of the elements of column name
.NullPointerException
- if v
contains null values. Nulls are not supported in collections
by CQL.<K,V> T setMap(String name, Map<K,V> v, com.google.common.reflect.TypeToken<K> keysType, com.google.common.reflect.TypeToken<V> valuesType)
name
to the provided map,
whose keys and values are of the provided Java types.
Please note that null
values inside collections are not supported by CQL.
Note about performance: this method is able to cache codecs used to serialize the map entries,
and thus should be used instead of setMap(String, Map)
whenever possible, because it performs significantly better.
name
- the name of the value to set; if name
is present multiple
times, all its values are set.v
- the value to set.keysType
- the type for the keys of the map.valuesType
- the type for the values of the map.IllegalArgumentException
- if name
is not a valid name for this object.InvalidTypeException
- if (any occurrence of) name
is
not a map type or if the elements (keys or values) of v
are not of
the type of the elements of column name
.NullPointerException
- if v
contains null values. Nulls are not supported in collections
by CQL.<E> T setSet(String name, Set<E> v)
name
to the
provided set.
Please note that null
values are not supported inside collection by CQL.
Note about performance: this method must perform a runtime inspection of the provided map, in order to guess the best codec to serialize the set elements. The result of such inspection cannot be cached and thus must be performed for each invocation of this method, which may incur in a performance penalty.
Furthermore, if two or more codecs are available
for the underlying CQL type (set
), which one will be used will depend
on the actual object being serialized.
For these reasons, it is generally preferable to use the more
deterministic methods setSet(String, Set, Class)
or
setSet(String, Set, TypeToken)
.
name
- the name of the value to set; if name
is present multiple
times, all its values are set.v
- the value to set.IllegalArgumentException
- if name
is not a valid name for this object.InvalidTypeException
- if (any occurrence of) name
is
not a map type or if the elements of v
are not of the type of
the elements of column name
.NullPointerException
- if v
contains null values. Nulls are not supported in collections
by CQL.<E> T setSet(String name, Set<E> v, Class<E> elementsClass)
name
to the provided set,
whose elements are of the provided Java class.
Please note that null
values inside collections are not supported by CQL.
Note about performance: this method is able to cache codecs used to serialize the set elements,
and thus should be used instead of setSet(String, Set)
whenever possible, because it performs significantly better.
name
- the name of the value to set; if name
is present multiplev
- the value to set.elementsClass
- the class for the elements of the set.IllegalArgumentException
- if name
is not a valid name for this object.InvalidTypeException
- if (any occurrence of) name
is
not a map type or if the elements (keys or values) of v
are not of
the type of the elements of column name
.NullPointerException
- if v
contains null values. Nulls are not supported in collections
by CQL.<E> T setSet(String name, Set<E> v, com.google.common.reflect.TypeToken<E> elementsType)
name
to the provided set,
whose elements are of the provided Java type.
Please note that null
values inside collections are not supported by CQL.
Note about performance: this method is able to cache codecs used to serialize the set elements,
and thus should be used instead of setSet(String, Set)
whenever possible, because it performs significantly better.
name
- the name of the value to set; if name
is present multiplev
- the value to set.elementsType
- the type for the elements of the set.IllegalArgumentException
- if name
is not a valid name for this object.InvalidTypeException
- if (any occurrence of) name
is
not a map type or if the elements (keys or values) of v
are not of
the type of the elements of column name
.NullPointerException
- if v
contains null values. Nulls are not supported in collections
by CQL.T setUDTValue(String name, UDTValue v)
name
to the
provided UDT value.name
- the name of the value to set; if name
is present multiple
times, all its values are set.v
- the value to set.IllegalArgumentException
- if name
is not a valid name for this object.InvalidTypeException
- if value i
is not a UDT value or if its definition
does not correspond to the one of v
.InvalidTypeException
- if (any occurrence of) name
is
not a UDT value or if the definition of column name
does not correspond to
the one of v
.T setTupleValue(String name, TupleValue v)
name
to the
provided tuple value.name
- the name of the value to set; if name
is present multiple
times, all its values are set.v
- the value to set.IllegalArgumentException
- if name
is not a valid name for this object.InvalidTypeException
- if (any occurrence of) name
is
not a tuple value or if the types of column name
do not correspond to
the ones of v
.T setToNull(String name)
name
to null
.
This is mainly intended for CQL types which map to native Java types.
name
- the name of the value to set; if name
is present multiple
times, all its values are set.IllegalArgumentException
- if name
is not a valid name for this object.<V> T setObject(String name, V v)
name
to the provided value.
Note about performance: this method must perform a runtime inspection of the provided object, in order to guess the best codec to serialize it. The result of such inspection cannot be cached and thus must be performed for each invocation of this method, which may incur in a performance penalty.
Furthermore, if two or more codecs are available for the underlying CQL type, which one will be used will depend on the actual object being serialized.
For these reasons, it is generally preferable to use the more
deterministic methods #set(String, V, Class)
or #set(String, V, TypeToken)
instead.
name
- the name of the value to set; if name
is present multiple
times, all its values are set.v
- the value to set; may be null
.IndexOutOfBoundsException
- if i
is not a valid index for this object.<V> T set(String name, V v, Class<V> targetClass)
name
to the provided value of the provided Java class.
A suitable TypeCodec
instance for the underlying CQL type and the provided class must
have been previously registered with the CodecRegistry
currently in use.
This method should be used instead of setObject(String, Object)
in cases
where more than one codec is registered for the same CQL type; specifying the Java class
allows the CodecRegistry
to narrow down the search and return only an exactly-matching codec (if any),
thus avoiding any risk of ambiguity.
name
- the name of the value to set; if name
is present multiple
times, all its values are set.v
- the value to set; may be null
.targetClass
- The Java class to convert to; must not be null
;IndexOutOfBoundsException
- if i
is not a valid index for this object.<V> T set(String name, V v, com.google.common.reflect.TypeToken<V> targetType)
name
to the provided value of the provided Java type.
A suitable TypeCodec
instance for the underlying CQL type and the provided class must
have been previously registered with the CodecRegistry
currently in use.
This method should be used instead of setObject(String, Object)
in cases
where more than one codec is registered for the same CQL type; specifying the Java class
allows the CodecRegistry
to narrow down the search and return only an exactly-matching codec (if any),
thus avoiding any risk of ambiguity.
name
- the name of the value to set; if name
is present multiple
times, all its values are set.v
- the value to set; may be null
.targetType
- The Java type to convert to; must not be null
;IndexOutOfBoundsException
- if i
is not a valid index for this object.<V> T set(String name, V v, TypeCodec<V> codec)
name
to the provided value,
converted using the given TypeCodec
.
Note that this method allows to entirely bypass the CodecRegistry
currently in use
and forces the driver to use the given codec instead.
It is the caller's responsibility to ensure that the given codec accepts
the underlying CQL type; failing to do so may result in InvalidTypeException
s being thrown.
name
- the name of the value to set; if name
is present multiple
times, all its values are set.v
- the value to set; may be null
.codec
- The TypeCodec
to use to serialize the value; may not be null
.InvalidTypeException
- if the given codec does not accept
the underlying CQL type.IndexOutOfBoundsException
- if i
is not a valid index for this object.Copyright © 2012–2015. All rights reserved.