Elffuss BraidHub

kikocis/java-driver public

Update codec-related Javadocs.
Changeset2ce86b39619b9ca8fca9ac661b1b5efde8be1646379748075e32887e128e46c5
Authorolim7t <omichallat+github@gmail.com> · 2015-10-15 20:09 +02:00
Committerolim7t <omichallat+github@gmail.com> · 2015-10-18 20:14 +02:00
Parents7c8de89c8f6b

Browse the files at this changeset

5 files changed

modified driver-core/src/main/java/com/datastax/driver/core/CodecRegistry.java +119 −126
@@ -39,110 +39,113 @@
3939 import static com.datastax.driver.core.DataType.Name.SET;
4040
4141 /**
42- * A registry for {@link TypeCodec codec}s. When the driver
43- * needs to serialize or deserialize an object,
44- * it will lookup in the registry for
45- * a suitable codec.
42+ * A registry for {@link TypeCodec}s. When the driver needs to serialize or deserialize a Java type to/from CQL,
43+ * it will lookup in the registry for a suitable codec. The registry is initialized with default codecs that handle
44+ * basic conversions (e.g. CQL {@code text} to {@code java.lang.String}), and users can add their own. Complex
45+ * codecs can also be generated on-the-fly from simpler ones (more details below).
4646 *
47- * <h3>Usage</h3>
47+ * <h3>Creating a registry</h3>
4848 *
4949 * <p>
50- * By default, the driver uses the CodecRegistry's {@link CodecRegistry#DEFAULT_INSTANCE},
51- * a shareable instance that initially contains all the built-in codecs required by the driver.
52- *
53- * <p>
54- * For most users, the default instance is good enough and
55- * they won't need to manipulate {@link CodecRegistry} instances directly.
56- * Only those willing to {@link #register(TypeCodec) register} user-defined codecs are required to do so:
50+ * By default, the driver uses {@link CodecRegistry#DEFAULT_INSTANCE}, a shareable, JVM-wide instance initialized with
51+ * built-in codecs for all the base CQL types.
52+ * The only reason to create your own instances is if you have multiple {@code Cluster} objects that use different
53+ * sets of codecs. In that case, use {@link com.datastax.driver.core.Cluster.Builder#withCodecRegistry(CodecRegistry)}
54+ * to associate the registry with the cluster:
5755 *
5856 * <pre>
59- * CodecRegistry myCodecRegistry;
60- * // use the default instance
61- * myCodecRegistry = CodecRegistry.DEFAULT_INSTANCE;
62- * // or alternatively, create a new one
63- * myCodecRegistry = new CodecRegistry();
64- * // then register additional codecs
57+ * {@code
58+ * CodecRegistry myCodecRegistry = new CodecRegistry();
6559 * myCodecRegistry.register(myCodec1, myCodec2, myCodec3);
66- * </pre>
67- *
68- * <p>
69- * To be used by the driver, {@link CodecRegistry} instances must then
70- * be associated with a {@link Cluster} instance:
71- *
72- * <pre>
73- * CodecRegistry myCodecRegistry = ...
7460 * Cluster cluster = Cluster.builder().withCodecRegistry(myCodecRegistry).build();
75- * </pre>
7661 *
77- * To retrieve the {@link CodecRegistry} instance associated with a Cluster, do the
78- * following:
79- *
80- * <pre>
62+ * // To retrieve the registry later:
8163 * CodecRegistry registry = cluster.getConfiguration().getCodecRegistry();
82- * </pre>
83- *
84- * <h3>Example</h3>
85- *
86- * <p>
87- * Suppose that one wants to have all CQL timestamps seamlessly
88- * converted to {@code java.time.DateTime} instances and vice versa; the following
89- * code contains the necessary steps to achieve this:
90- *
91- * <pre>
92- * // 1. Instantiate the custom codec
93- * TypeCodec&lt;DateTime> timestampCodec = ...
94- * // 2. Register the codec
95- * CodecRegistry.DEFAULT_INSTANCE.register(timestampCodec);
96- * </pre>
64+ * }</pre>
9765 *
98- * <p>
99- * Read the
100- * <a href="http://datastax.github.io/java-driver/features/custom_codecs">online documentation</a>
101- * for more examples.
102- *
103- * <h3>Notes</h3>
66+ * {@code CodecRegistry} instances are thread-safe.
10467 *
10568 * <p>
106- * <strong>Registration order</strong>: the order in which codecs are registered matters:
107- * when looking for a suitable codec, the registry will consider
108- * all registered codecs <em>in the order they were registered</em>, and
109- * will pick the first matching one.
69+ * It is possible to turn on log messages by setting the {@code com.datastax.driver.core.CodecRegistry} logger
70+ * level to {@code TRACE}. Beware that the registry can be very verbose at this log level.
11071 *
111- * <p>
112- * If a codec is registered while another codec already handles the <em>exact same</em>
113- * CQL-to-Java mapping, that codec will never be used (unless
114- * the user forces its usage through e.g. {@link GettableByIndexData#get(int, TypeCodec)}).
115- * In order words, it is not possible to replace an existing codec,
116- * specially the built-in ones; it is only possible to enrich the initial
117- * set of codecs with new ones.
72+ * <h3>Registering and using custom codecs</h3>
11873 *
119- * <p>
120- * <strong>On-the-fly codec instantiation</strong>: When a {@link CodecRegistry}
121- * cannot find a suitable codec among all registered codecs,
122- * it will attempt to create such a codec on-the-fly. If the creation succeeds, that codec is returned;
123- * otherwise, a {@link CodecNotFoundException} is thrown.
74+ * To create a custom codec, write a class that extends {@link TypeCodec}, create an instance, and pass it to one of
75+ * the {@link #register(TypeCodec) register} methods:
12476 *
125- * <p>
126- * Note that {@link CodecRegistry} instances can only create codecs in very limited situations:
77+ * <pre>
78+ * {@code
79+ * // A codec that maps timestamps to JDK8's LocalDate
80+ * class LocalDateCodec extends TypeCodec<LocalDate> {
81+ * ...
82+ * }
83+ * myCodecRegistry.register(new LocalDateCodec());
84+ * }</pre>
85+ *
86+ * The conversion will be available to:
87+ * <ul>
88+ * <li>all driver types that implement {@link GettableByIndexData}, {@link GettableByNameData},
89+ * {@link SettableByIndexData} and/or {@link SettableByNameData}. Namely: {@link Row},
90+ * {@link BoundStatement}, {@link UDTValue} and {@link TupleValue};</li>
91+ * <li>{@link Session#newSimpleStatement(String, Object...) simple statements}.</li>
92+ * </ul>
93+ *
94+ * Example:
95+ * <pre>
96+ * {@code
97+ * Row row = session.executeQuery("select date from some_table where pk = 1").one();
98+ * LocalDate date = row.get(0, LocalDate.class); // uses LocalDateCodec registered above
99+ * }</pre>
100+ *
101+ * You can also bypass the codec registry by passing a standalone codec instance to methods such as
102+ * {@link GettableByIndexData#get(int, TypeCodec)}.
103+ *
104+ * <h3>Codec generation</h3>
105+ *
106+ * When a {@code CodecRegistry} cannot find a suitable codec among existing ones, it will attempt to create it on-the-fly:
107+ * It can manage:
108+ *
109+ * <ul>
110+ * <li>collections of known types. For example, if you registered a {@code TypeCodec<LocalDate>}, you get
111+ * {@code List<LocalDate>>} handled for free. This works recursively for nested collections;</li>
112+ * <li>{@link UserType user types}, mapped to {@link UDTValue} objects. Custom codecs are available recursively
113+ * to the UDT's fields, so if one of your fields is a {@code timestamp} you can use your {@code LocaDateCodec} to retrieve
114+ * it as a {@code LocalDate};</li>
115+ * <li>{@link TupleType tuple types}, mapped to {@link TupleValue} (with the same rules for nested fields);</li>
116+ * <li>{@link com.datastax.driver.core.DataType.CustomType custom types}, mapped to {@code ByteBuffer}.</li>
117+ * </ul>
118+ *
119+ * If the codec registry encounters a mapping that it can't handle automatically, a {@link CodecNotFoundException} is thrown;
120+ * you'll need to register a custom codec for it.
121+ *
122+ * <h3>Performance and caching</h3>
123+ *
124+ * Whenever possible, the registry will cache the result of a codec lookup for a specific type mapping, including any generated
125+ * codec. For example, if you registered {@code LocalDateCodec} and ask the registry for a codec to convert a CQL
126+ * {@code list<timestamp>} to a Java {@code List<LocalDate>}:
127127 * <ol>
128- * <li>Codecs for {@link UserType user types} are created on the fly using {@link TypeCodec#userType(UserType)};</li>
129- * <li>Codecs for {@link TupleType tuple types} are created on the fly using {@link TypeCodec#tuple(TupleType)}};</li>
130- * <li>Codecs for collections are created on the fly using {@link TypeCodec#list(TypeCodec)}}, {@link TypeCodec#set(TypeCodec)}} and
131- * {@link TypeCodec#map(TypeCodec, TypeCodec)}}, if their element types can be handled by existing codecs (or codecs that can
132- * themselves be generated).</li>
133- * <li>Codecs for {@link com.datastax.driver.core.DataType.CustomType custom types} are created on the fly using {@link TypeCodec#custom(DataType.CustomType)};</li>
128+ * <li>the first lookup will generate a {@code TypeCodec<List<LocalDate>>} from {@code LocalDateCodec}, and put it in
129+ * the cache;</li>
130+ * <li>the second lookup will hit the cache directly, and reuse the previously generated instance.</li>
134131 * </ol>
135- * Other combinations of Java and CQL types cannot have their codecs created on the fly;
136- * such codecs must be manually registered.
137- * <p>
138132 *
139- * <strong>Debugging the codec registry</strong>: it is possible to turn on log messages
140- * by setting the {@code com.datastax.driver.core.CodecRegistry} logger level to {@code TRACE}.
141- * Beware that the registry can be very verbose at this log level.
133+ * The javadoc for each {@link #codecFor(DataType) codecFor} variant specifies whether the result can be cached or not.
142134 *
143- * <p>
144- * <strong>Thread-safety</strong>: {@link CodecRegistry} instances are thread-safe.
135+ * <h3>Codec order</h3>
136+ *
137+ * When the registry looks up a codec, the rules of precedence are:
145138 *
139+ * <ul>
140+ * <li>if a result was previously cached for that mapping, it is returned;</li>
141+ * <li>otherwise, the registry checks the list of "basic" codecs: the default ones, and the ones that were explicitly
142+ * registered (in the order that they were registered). It calls each codec's {@code accepts} methods to determine if
143+ * it can handle the mapping, and if so returns it;</li>
144+ * <li>otherwise, the registry tries to generate a codec, according to the rules outlined above.</li>
145+ * </ul>
146+ *
147+ * It is currently impossible to override an existing codec. If you try to do so, {@link #register(TypeCodec)} will log a
148+ * warning and ignore it.
146149 */
147150 public final class CodecRegistry {
148151
@@ -172,10 +175,9 @@
172175 );
173176
174177 /**
175- * A default instance of CodecRegistry.
176- * For most applications, sharing a single instance of CodecRegistry is fine.
177- * But note that any codec registered with this instance will immediately
178- * be available for all its clients.
178+ * The default {@code CodecRegistry} instance.
179+ *
180+ * It will be shared among all {@link Cluster} instances that were not explicitly built with a different instance.
179181 */
180182 public static final CodecRegistry DEFAULT_INSTANCE = new CodecRegistry();
181183
@@ -298,7 +300,7 @@
298300 private final LoadingCache<CacheKey, TypeCodec<?>> cache;
299301
300302 /**
301- * Creates a default CodecRegistry instance with default cache options.
303+ * Creates a new instance initialized with built-in codecs for all the base CQL types.
302304 */
303305 public CodecRegistry() {
304306 this.codecs = new CopyOnWriteArrayList<TypeCodec<?>>(PRIMITIVE_CODECS);
@@ -323,8 +325,8 @@
323325 * <p>
324326 * This method will log a warning and ignore the codec if it collides with a previously registered one.
325327 * Note that this check is not done in a completely thread-safe manner; codecs should typically be registered
326- * at application startup, not in a highly concurrent context (if a race condition occurs, the worst outcome
327- * is that no warning gets logged, and the codec gets registered but will never actually be used).
328+ * at application startup, not in a highly concurrent context (if a race condition occurs, the worst possible
329+ * outcome is that no warning gets logged, and the codec gets registered but will never actually be used).
328330 *
329331 * @param newCodec The codec to add to the registry.
330332 * @return this CodecRegistry (for method chaining).
@@ -379,22 +381,20 @@
379381 /**
380382 * Returns a {@link TypeCodec codec} that accepts the given value.
381383 * <p>
382- * This method takes an actual Java object and tries to locate a suitable codec for it.
383- * For this reason, codecs must perform a {@link TypeCodec#accepts(Object) "manual" inspection}
384- * of the object to determine if they can accept it or not, which, depending on the implementations,
385- * can be an expensive operation; besides, the resulting codec cannot be cached.
384+ * This method takes an arbitrary Java object and tries to locate a suitable codec for it.
385+ * Codecs must perform a {@link TypeCodec#accepts(Object) runtime inspection} of the object to determine
386+ * if they can accept it or not, which, depending on the implementations, can be expensive; besides, the
387+ * resulting codec cannot be cached.
386388 * Therefore there might be a performance penalty when using this method.
387389 * <p>
388- * Furthermore, this method would return the first matching codec, regardless of its accepted {@link DataType CQL type}.
389- * For this reason, this method might not return the most accurate codec and should be
390- * reserved for situations where the target CQL type is not available or unknown.
391- * In the Java driver, this happens mainly when serializing a value in a {@link SimpleStatement}
392- * or in the {@link com.datastax.driver.core.querybuilder.QueryBuilder}, where no CQL type information
393- * is available.
394- * <p>
395- * Regular application code should avoid using this method.
390+ * Furthermore, this method returns the first matching codec, regardless of its accepted CQL type.
391+ * It should be reserved for situations where the target CQL type is not available or unknown.
392+ * In the Java driver, this happens mainly when serializing a value in a
393+ * {@link Session#newSimpleStatement(String, Object...) SimpleStatement} or in the
394+ * {@link com.datastax.driver.core.querybuilder.QueryBuilder}, where no CQL type information is available.
396395 * <p>
397- * Codecs returned by this method are <em>NOT</em> cached.
396+ * Codecs returned by this method are <em>NOT</em> cached (see the {@link CodecRegistry top-level documentation}
397+ * of this class for more explanations about caching).
398398 *
399399 * @param value The value the codec should accept; must not be {@code null}.
400400 * @return A suitable codec.
@@ -407,13 +407,13 @@
407407 /**
408408 * Returns a {@link TypeCodec codec} that accepts the given {@link DataType CQL type}.
409409 * <p>
410- * This method would return the first matching codec, regardless of its accepted Java type.
411- * For this reason, this method might not return the most accurate codec and should be
412- * reserved for situations where the runtime type is not available or unknown.
410+ * This method returns the first matching codec, regardless of its accepted Java type.
411+ * It should be reserved for situations where the Java type is not available or unknown.
413412 * In the Java driver, this happens mainly when deserializing a value using the
414- * {@link AbstractGettableData#getObject(int)} method.
413+ * {@link GettableByIndexData#getObject(int) getObject} method.
415414 * <p>
416- * Codecs returned by this method are cached.
415+ * Codecs returned by this method are cached (see the {@link CodecRegistry top-level documentation}
416+ * of this class for more explanations about caching).
417417 *
418418 * @param cqlType The {@link DataType CQL type} the codec should accept; must not be {@code null}.
419419 * @return A suitable codec.
@@ -430,12 +430,8 @@
430430 * This method can only handle raw (non-parameterized) Java types.
431431 * For parameterized types, use {@link #codecFor(DataType, TypeToken)} instead.
432432 * <p>
433- * Note that type inheritance needs special care.
434- * If a codec accepts a Java type that is assignable to the
435- * given Java type, that codec may be returned if it is found first
436- * in the registry, <em>even if another codec is a better match</em>.
437- * <p>
438- * Codecs returned by this method are cached.
433+ * Codecs returned by this method are cached (see the {@link CodecRegistry top-level documentation}
434+ * of this class for more explanations about caching).
439435 *
440436 * @param cqlType The {@link DataType CQL type} the codec should accept; must not be {@code null}.
441437 * @param javaType The Java type the codec should accept; can be {@code null}.
@@ -452,12 +448,8 @@
452448 * <p>
453449 * This method handles parameterized types thanks to Guava's {@link TypeToken} API.
454450 * <p>
455- * Note that type inheritance needs special care.
456- * If a codec accepts a Java type that is assignable to the
457- * given Java type, that codec may be returned if it is found first
458- * in the registry, <em>even if another codec is a better match</em>.
459- * <p>
460- * Codecs returned by this method are cached.
451+ * Codecs returned by this method are cached (see the {@link CodecRegistry top-level documentation}
452+ * of this class for more explanations about caching).
461453 *
462454 * @param cqlType The {@link DataType CQL type} the codec should accept; must not be {@code null}.
463455 * @param javaType The {@link TypeToken Java type} the codec should accept; can be {@code null}.
@@ -472,13 +464,14 @@
472464 * Returns a {@link TypeCodec codec} that accepts the given {@link DataType CQL type}
473465 * and the given value.
474466 * <p>
475- * This method takes an actual Java object and tries to locate a suitable codec for it.
476- * For this reason, codecs must perform a {@link TypeCodec#accepts(Object) "manual" inspection}
477- * of the object to determine if they can accept it or not, which, depending on the implementations,
478- * can be an expensive operation; besides, the resulting codec cannot be cached.
467+ * This method takes an arbitrary Java object and tries to locate a suitable codec for it.
468+ * Codecs must perform a {@link TypeCodec#accepts(Object) runtime inspection} of the object to determine
469+ * if they can accept it or not, which, depending on the implementations, can be expensive; besides, the
470+ * resulting codec cannot be cached.
479471 * Therefore there might be a performance penalty when using this method.
480472 * <p>
481- * Codecs returned by this method are <em>NOT</em> cached.
473+ * Codecs returned by this method are <em>NOT</em> cached (see the {@link CodecRegistry top-level documentation}
474+ * of this class for more explanations about caching).
482475 *
483476 * @param cqlType The {@link DataType CQL type} the codec should accept; can be {@code null}.
484477 * @param value The value the codec should accept; must not be {@code null}.
modified driver-core/src/main/java/com/datastax/driver/core/GettableByIndexData.java +153 −50
@@ -23,10 +23,12 @@
2323
2424 import com.google.common.reflect.TypeToken;
2525
26+import com.datastax.driver.core.exceptions.CodecNotFoundException;
27+
2628 import com.datastax.driver.core.exceptions.InvalidTypeException;
2729
2830 /**
29- * Collection of (typed) CQL values that can be retrieved by index (starting a 0).
31+ * Collection of (typed) CQL values that can be retrieved by index (starting at 0).
3032 */
3133 public interface GettableByIndexData {
3234
@@ -43,121 +45,169 @@
4345
4446 /**
4547 * Returns the {@code i}th value as a boolean.
48+ * <p>
49+ * This method uses the {@link CodecRegistry} to find a codec to convert the underlying CQL type to a Java {@code boolean}
50+ * (for CQL type {@code boolean}, this will be the built-in codec).
4651 *
4752 * @param i the index ({@code 0 <= i < size()}) to retrieve.
48- * @return the boolean value of the {@code i}th element. If the
49- * value is NULL, {@code false} is returned.
53+ * @return the boolean value of the {@code i}th element. If the value is NULL, {@code false} is returned.
54+ * If you need to distinguish NULL and false values, check first with {@link #isNull(int)} or use {@code get(i, Boolean.class)}.
5055 *
5156 * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object.
57+ * @throws CodecNotFoundException if there is no registered codec to convert the element's CQL
58+ * type to a boolean.
5259 */
5360 public boolean getBool(int i);
5461
5562 /**
5663 * Returns the {@code i}th value as a byte.
64+ * <p>
65+ * This method uses the {@link CodecRegistry} to find a codec to convert the underlying CQL type to a Java {@code byte}
66+ * (for CQL type {@code tinyint}, this will be the built-in codec).
5767 *
5868 * @param i the index ({@code 0 <= i < size()}) to retrieve.
59- * @return the value of the {@code i}th element as a byte. If the
60- * value is NULL, {@code 0} is returned.
69+ * @return the value of the {@code i}th element as a byte. If the value is NULL, {@code 0} is returned.
70+ * If you need to distinguish NULL and 0, check first with {@link #isNull(int)} or use {@code get(i, Byte.class)}.
6171 *
6272 * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object.
73+ * @throws CodecNotFoundException if there is no registered codec to convert the element's CQL
74+ * type to a byte.
6375 */
6476 public byte getByte(int i);
6577
6678 /**
6779 * Returns the {@code i}th value as a short.
80+ * <p>
81+ * This method uses the {@link CodecRegistry} to find a codec to convert the underlying CQL type to a Java {@code short}
82+ * (for CQL type {@code smallint}, this will be the built-in codec).
6883 *
6984 * @param i the index ({@code 0 <= i < size()}) to retrieve.
70- * @return the value of the {@code i}th element as a short. If the
71- * value is NULL, {@code 0} is returned.
85+ * @return the value of the {@code i}th element as a short. If the value is NULL, {@code 0} is returned.
86+ * If you need to distinguish NULL and 0, check first with {@link #isNull(int)} or use {@code get(i, Short.class)}.
7287 *
7388 * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object.
89+ * @throws CodecNotFoundException if there is no registered codec to convert the element's CQL
90+ * type to a short.
7491 */
7592 public short getShort(int i);
7693
7794 /**
7895 * Returns the {@code i}th value as an integer.
96+ * <p>
97+ * This method uses the {@link CodecRegistry} to find a codec to convert the underlying CQL type to a Java {@code int}
98+ * (for CQL type {@code int}, this will be the built-in codec).
7999 *
80100 * @param i the index ({@code 0 <= i < size()}) to retrieve.
81- * @return the value of the {@code i}th element as an integer. If the
82- * value is NULL, {@code 0} is returned.
101+ * @return the value of the {@code i}th element as an integer. If the value is NULL, {@code 0} is returned.
102+ * If you need to distinguish NULL and 0, check first with {@link #isNull(int)} or use {@code get(i, Integer.class)}.
83103 *
84104 * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object.
105+ * @throws CodecNotFoundException if there is no registered codec to convert the element's CQL
106+ * type to an int.
85107 */
86108 public int getInt(int i);
87109
88110 /**
89111 * Returns the {@code i}th value as a long.
112+ * <p>
113+ * This method uses the {@link CodecRegistry} to find a codec to convert the underlying CQL type to a Java {@code byte}
114+ * (for CQL types {@code bigint} and {@code counter}, this will be the built-in codec).
90115 *
91116 * @param i the index ({@code 0 <= i < size()}) to retrieve.
92- * @return the value of the {@code i}th element as a long. If the
93- * value is NULL, {@code 0L} is returned.
117+ * @return the value of the {@code i}th element as a long. If the value is NULL, {@code 0L} is returned.
118+ * If you need to distinguish NULL and 0L, check first with {@link #isNull(int)} or use {@code get(i, Long.class)}.
94119 *
95120 * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object.
121+ * @throws CodecNotFoundException if there is no registered codec to convert the element's CQL
122+ * type to a long.
96123 */
97124 public long getLong(int i);
98125
99126 /**
100127 * Returns the {@code i}th value as a date.
128+ * <p>
129+ * This method uses the {@link CodecRegistry} to find a codec to convert the underlying CQL type to a {@code Date}
130+ * (for CQL type {@code timestamp}, this will be the built-in codec).
101131 *
102132 * @param i the index ({@code 0 <= i < size()}) to retrieve.
103133 * @return the value of the {@code i}th element as a data. If the
104134 * value is NULL, {@code null} is returned.
105135 *
106136 * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object.
137+ * @throws CodecNotFoundException if there is no registered codec to convert the element's CQL
138+ * type to a {@code Date}.
107139 */
108140 public Date getTimestamp(int i);
109141
110142 /**
111143 * Returns the {@code i}th value as a date (without time).
144+ * <p>
145+ * This method uses the {@link CodecRegistry} to find a codec to convert the underlying CQL type to a {@link LocalDate}
146+ * (for CQL type {@code date}, this will be the built-in codec).
112147 *
113148 * @param i the index ({@code 0 <= i < size()}) to retrieve.
114149 * @return the value of the {@code i}th element as an date. If the
115150 * value is NULL, {@code null} is returned.
116151 *
117152 * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object.
153+ * @throws CodecNotFoundException if there is no registered codec to convert the element's CQL
154+ * type to a {@code LocalDate}.
118155 */
119156 public LocalDate getDate(int i);
120157
121158 /**
122159 * Returns the {@code i}th value as a long in nanoseconds since midnight.
160+ * <p>
161+ * This method uses the {@link CodecRegistry} to find a codec to convert the underlying CQL type to a Java {@code long}
162+ * (for CQL type {@code time}, this will be the built-in codec).
123163 *
124164 * @param i the index ({@code 0 <= i < size()}) to retrieve.
125165 * @return the value of the {@code i}th element as a long. If the
126166 * value is NULL, {@code 0L} is returned.
127167 *
128168 * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object.
169+ * @throws CodecNotFoundException if there is no registered codec to convert the element's CQL
170+ * type to a long.
129171 */
130172 public long getTime(int i);
131173
132174 /**
133175 * Returns the {@code i}th value as a float.
176+ * <p>
177+ * This method uses the {@link CodecRegistry} to find a codec to convert the underlying CQL type to a Java {@code float}
178+ * (for CQL type {@code float}, this will be the built-in codec).
134179 *
135180 * @param i the index ({@code 0 <= i < size()}) to retrieve.
136- * @return the value of the {@code i}th element as a float. If the
137- * value is NULL, {@code 0.0f} is returned.
181+ * @return the value of the {@code i}th element as a float. If the value is NULL, {@code 0.0f} is returned.
182+ * If you need to distinguish NULL and 0.0f, check first with {@link #isNull(int)} or use {@code get(i, Float.class)}.
138183 *
139184 * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object.
185+ * @throws CodecNotFoundException if there is no registered codec to convert the element's CQL
186+ * type to a float.
140187 */
141188 public float getFloat(int i);
142189
143190 /**
144191 * Returns the {@code i}th value as a double.
192+ * <p>
193+ * This method uses the {@link CodecRegistry} to find a codec to convert the underlying CQL type to a Java {@code double}
194+ * (for CQL type {@code double}, this will be the built-in codec).
145195 *
146196 * @param i the index ({@code 0 <= i < size()}) to retrieve.
147- * @return the value of the {@code i}th element as a double. If the
148- * value is NULL, {@code 0.0} is returned.
197+ * @return the value of the {@code i}th element as a double. If the value is NULL, {@code 0.0} is returned.
198+ * If you need to distinguish NULL and 0.0, check first with {@link #isNull(int)} or use {@code get(i, Double.class)}.
149199 *
150200 * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object.
201+ * @throws CodecNotFoundException if there is no registered codec to convert the element's CQL
202+ * type to a double.
151203 */
152204 public double getDouble(int i);
153205
154206 /**
155- * Returns the {@code i}th value as a ByteBuffer.
156- *
157- * Note: this method always return the bytes composing the value, even if
158- * the column is not of type BLOB. That is, this method never throw an
159- * InvalidTypeException. However, if the type is not BLOB, it is up to the
160- * caller to handle the returned value correctly.
207+ * Returns the {@code i}th value as a {@code ByteBuffer}.
208+ * <p>
209+ * This method does not use any codec; it returns a copy of the binary representation of the value. It is up to the
210+ * caller to convert the returned value appropriately.
161211 *
162212 * @param i the index ({@code 0 <= i < size()}) to retrieve.
163213 * @return the value of the {@code i}th element as a ByteBuffer. If the
@@ -170,75 +220,104 @@
170220 /**
171221 * Returns the {@code i}th value as a byte array.
172222 * <p>
173- * Note that this method validate that the column is of type BLOB. If you want to retrieve
174- * the bytes for any type, use {@link #getBytesUnsafe(int)} instead.
223+ * This method uses the {@link CodecRegistry} to find a codec to convert the underlying CQL type to a Java {@code ByteBuffer}
224+ * (for CQL type {@code blob}, this will be the built-in codec).
175225 *
176226 * @param i the index ({@code 0 <= i < size()}) to retrieve.
177227 * @return the value of the {@code i}th element as a byte array. If the
178228 * value is NULL, {@code null} is returned.
179229 *
180230 * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object.
231+ * @throws CodecNotFoundException if there is no registered codec to convert the element's CQL
232+ * type to a {@code ByteBuffer}.
181233 */
182234 public ByteBuffer getBytes(int i);
183235
184236 /**
185237 * Returns the {@code i}th value as a string.
238+ * <p>
239+ * This method uses the {@link CodecRegistry} to find a codec to convert the underlying CQL type to a Java string
240+ * (for CQL types {@code text}, {@code varchar} and {@code ascii}, this will be the built-in codec).
186241 *
187242 * @param i the index ({@code 0 <= i < size()}) to retrieve.
188243 * @return the value of the {@code i}th element as a string. If the
189244 * value is NULL, {@code null} is returned.
190245 *
191246 * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object.
247+ * @throws CodecNotFoundException if there is no registered codec to convert the element's CQL
248+ * type to a string.
192249 */
193250 public String getString(int i);
194251
195252 /**
196253 * Returns the {@code i}th value as a variable length integer.
254+ * <p>
255+ * This method uses the {@link CodecRegistry} to find a codec to convert the underlying CQL type to a {@code BigInteger}
256+ * (for CQL type {@code varint}, this will be the built-in codec).
197257 *
198258 * @param i the index ({@code 0 <= i < size()}) to retrieve.
199259 * @return the value of the {@code i}th element as a variable
200260 * length integer. If the value is NULL, {@code null} is returned.
201261 *
202262 * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object.
263+ * @throws CodecNotFoundException if there is no registered codec to convert the element's CQL
264+ * type to a {@code BigInteger}.
203265 */
204266 public BigInteger getVarint(int i);
205267
206268 /**
207269 * Returns the {@code i}th value as a variable length decimal.
270+ * <p>
271+ * This method uses the {@link CodecRegistry} to find a codec to convert the underlying CQL type to a {@code BigDecimal}
272+ * (for CQL type {@code decimal}, this will be the built-in codec).
208273 *
209274 * @param i the index ({@code 0 <= i < size()}) to retrieve.
210275 * @return the value of the {@code i}th element as a variable
211276 * length decimal. If the value is NULL, {@code null} is returned.
212277 *
213278 * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object.
279+ * @throws CodecNotFoundException if there is no registered codec to convert the element's CQL
280+ * type to a {@code BigDecimal}.
214281 */
215282 public BigDecimal getDecimal(int i);
216283
217284 /**
218285 * Returns the {@code i}th value as a UUID.
286+ * <p>
287+ * This method uses the {@link CodecRegistry} to find a codec to convert the underlying CQL type to a {@code UUID}
288+ * (for CQL types {@code uuid} and {@code timeuuid}, this will be the built-in codec).
219289 *
220290 * @param i the index ({@code 0 <= i < size()}) to retrieve.
221291 * @return the value of the {@code i}th element as a UUID.
222292 * If the value is NULL, {@code null} is returned.
223293 *
224294 * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object.
295+ * @throws CodecNotFoundException if there is no registered codec to convert the element's CQL
296+ * type to a {@code UUID}.
225297 */
226298 public UUID getUUID(int i);
227299
228300 /**
229301 * Returns the {@code i}th value as an InetAddress.
302+ * <p>
303+ * This method uses the {@link CodecRegistry} to find a codec to convert the underlying CQL type to an {@code InetAddress}
304+ * (for CQL type {@code inet}, this will be the built-in codec).
230305 *
231306 * @param i the index ({@code 0 <= i < size()}) to retrieve.
232307 * @return the value of the {@code i}th element as an InetAddress.
233308 * If the value is NULL, {@code null} is returned.
234309 *
235310 * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object.
311+ * @throws CodecNotFoundException if there is no registered codec to convert the element's CQL
312+ * type to a {@code InetAddress}.
236313 */
237314 public InetAddress getInet(int i);
238315
239316 /**
240317 * Returns the {@code i}th value as a list.
241318 * <p>
319+ * This method uses the {@link CodecRegistry} to find a codec to convert the underlying CQL type to a list of the specified type.
320+ * <p>
242321 * If the type of the elements is generic, use {@link #getList(int, TypeToken)}.
243322 * <p>
244323 * Implementation note: the actual {@link List} implementation will depend
@@ -246,7 +325,7 @@
246325 * make no assumptions concerning its mutability nor its thread-safety.
247326 * Furthermore, the behavior of this method in respect to CQL {@code NULL} values is also
248327 * codec-dependent. By default, the driver will return mutable instances, and
249- * a CQL {@code NULL} will mapped to an empty collection (note that Cassandra
328+ * a CQL {@code NULL} will be mapped to an empty collection (note that Cassandra
250329 * makes no distinction between {@code NULL} and an empty collection).
251330 *
252331 * @param i the index ({@code 0 <= i < size()}) to retrieve.
@@ -255,12 +334,16 @@
255334 * {@code T} objects.
256335 *
257336 * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object.
337+ * @throws CodecNotFoundException if there is no registered codec to convert the element's CQL
338+ * type to a list.
258339 */
259340 public <T> List<T> getList(int i, Class<T> elementsClass);
260341
261342 /**
262343 * Returns the {@code i}th value as a list.
263344 * <p>
345+ * This method uses the {@link CodecRegistry} to find a codec to convert the underlying CQL type to a list of the specified type.
346+ * <p>
264347 * Use this variant with nested collections, which produce a generic element type:
265348 * <pre>
266349 * {@code List<List<String>> l = row.getList(1, new TypeToken<List<String>>() {});}
@@ -280,12 +363,16 @@
280363 * {@code T} objects.
281364 *
282365 * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object.
366+ * @throws CodecNotFoundException if there is no registered codec to convert the element's CQL
367+ * type to a list.
283368 */
284369 public <T> List<T> getList(int i, TypeToken<T> elementsType);
285370
286371 /**
287372 * Returns the {@code i}th value as a set.
288373 * <p>
374+ * This method uses the {@link CodecRegistry} to find a codec to convert the underlying CQL type to a set of the specified type.
375+ * <p>
289376 * If the type of the elements is generic, use {@link #getSet(int, TypeToken)}.
290377 * <p>
291378 * Implementation note: the actual {@link Set} implementation will depend
@@ -302,12 +389,16 @@
302389 * {@code T} objects.
303390 *
304391 * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object.
392+ * @throws CodecNotFoundException if there is no registered codec to convert the element's CQL
393+ * type to a set.
305394 */
306395 public <T> Set<T> getSet(int i, Class<T> elementsClass);
307396
308397 /**
309398 * Returns the {@code i}th value as a set.
310399 * <p>
400+ * This method uses the {@link CodecRegistry} to find a codec to convert the underlying CQL type to a set of the specified type.
401+ * <p>
311402 * Use this variant with nested collections, which produce a generic element type:
312403 * <pre>
313404 * {@code Set<List<String>> l = row.getSet(1, new TypeToken<List<String>>() {});}
@@ -327,12 +418,16 @@
327418 * {@code T} objects.
328419 *
329420 * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object.
421+ * @throws CodecNotFoundException if there is no registered codec to convert the element's CQL
422+ * type to a set.
330423 */
331424 public <T> Set<T> getSet(int i, TypeToken<T> elementsType);
332425
333426 /**
334427 * Returns the {@code i}th value as a map.
335428 * <p>
429+ * This method uses the {@link CodecRegistry} to find a codec to convert the underlying CQL type to a map of the specified types.
430+ * <p>
336431 * If the type of the keys and/or values is generic, use {@link #getMap(int, TypeToken, TypeToken)}.
337432 * <p>
338433 * Implementation note: the actual {@link Map} implementation will depend
@@ -350,6 +445,8 @@
350445 * {@code K} to {@code V} objects.
351446 *
352447 * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object.
448+ * @throws CodecNotFoundException if there is no registered codec to convert the element's CQL
449+ * type to a map.
353450 */
354451 public <K, V> Map<K, V> getMap(int i, Class<K> keysClass, Class<V> valuesClass);
355452
@@ -357,6 +454,8 @@
357454 /**
358455 * Returns the {@code i}th value as a map.
359456 * <p>
457+ * This method uses the {@link CodecRegistry} to find a codec to convert the underlying CQL type to a map of the specified types.
458+ * <p>
360459 * Use this variant with nested collections, which produce a generic element type:
361460 * <pre>
362461 * {@code Map<Int, List<String>> l = row.getMap(1, TypeToken.of(Integer.class), new TypeToken<List<String>>() {});}
@@ -377,57 +476,68 @@
377476 * {@code K} to {@code V} objects.
378477 *
379478 * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object.
479+ * @throws CodecNotFoundException if there is no registered codec to convert the element's CQL
480+ * type to a map.
380481 */
381482 public <K, V> Map<K, V> getMap(int i, TypeToken<K> keysType, TypeToken<V> valuesType);
382483
383484 /**
384485 * Return the {@code i}th value as a UDT value.
486+ * <p>
487+ * This method uses the {@link CodecRegistry} to find a codec to convert the underlying CQL type to a {@code UDTValue}
488+ * (if the CQL type is a UDT, the registry will generate a codec automatically).
385489 *
386490 * @param i the index ({@code 0 <= i < size()}) to retrieve.
387491 * @return the value of the {@code i}th element as a UDT value. If the value is NULL,
388492 * then {@code null} will be returned.
389493 *
390494 * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object.
495+ * @throws CodecNotFoundException if there is no registered codec to convert the element's CQL
496+ * type to a {@code UDTValue}.
391497 */
392498 public UDTValue getUDTValue(int i);
393499
394500 /**
395501 * Return the {@code i}th value as a tuple value.
502+ * <p>
503+ * This method uses the {@link CodecRegistry} to find a codec to convert the underlying CQL type to a {@code TupleValue}
504+ * (if the CQL type is a tuple, the registry will generate a codec automatically).
396505 *
397506 * @param i the index ({@code 0 <= i < size()}) to retrieve.
398507 * @return the value of the {@code i}th element as a tuple value. If the value is NULL,
399508 * then {@code null} will be returned.
400509 *
401510 * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object.
511+ * @throws CodecNotFoundException if there is no registered codec to convert the element's CQL
512+ * type to a {@code TupleValue}.
402513 */
403514 public TupleValue getTupleValue(int i);
404515
405516 /**
406517 * Returns the {@code i}th value as the Java type matching its CQL type.
407518 * <p>
408- * Note: if two or more codecs are available
409- * for the underlying CQL type, <em>the one that will be used will be
410- * the first one to be registered.</em>.
519+ * This method uses the {@link CodecRegistry} to find the first codec that handles the underlying CQL type. The Java type
520+ * of the returned object will be determined by the codec that was selected.
411521 * <p>
412- * For these reasons, it is generally preferable to use the more
413- * deterministic methods {@link #get(int, Class)} or {@link #get(int, TypeToken)} instead.
522+ * Use this method to dynamically inspect elements when types aren't known in advance, for instance if you're writing a
523+ * generic row logger. If you know the target Java type, it is generally preferable to use typed getters, such as the
524+ * ones for built-in types ({@link #getBool(int)}, {@link #getInt(int)}, etc.), or {@link #get(int, Class)} and
525+ * {@link #get(int, TypeToken)} for custom types.
414526 *
415527 * @param i the index to retrieve.
416528 * @return the value of the {@code i}th value as the Java type matching its CQL type.
417529 * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object.
530+ *
531+ * @see CodecRegistry#codecFor(DataType)
418532 */
419533 public Object getObject(int i);
420534
421535 /**
422536 * Returns the {@code i}th value converted to the given Java type.
423537 * <p>
424- * A suitable {@link TypeCodec} instance for the underlying CQL type and {@code targetClass} must
425- * have been previously registered with the {@link CodecRegistry} currently in use.
538+ * This method uses the {@link CodecRegistry} to find a codec to convert the underlying CQL type to the given Java type.
426539 * <p>
427- * This method should be used instead of {@link #getObject(int)} in cases
428- * where more than one codec is registered for the same CQL type; specifying the Java class
429- * allows the {@link CodecRegistry} to narrow down the search and return only an exactly-matching codec (if any),
430- * thus avoiding any risk of ambiguity.
540+ * If the target type is generic, use {@link #get(int, TypeToken)}.
431541 * <p>
432542 * Implementation note: the actual object returned by this method will depend
433543 * on the {@link TypeCodec codec} being used; therefore, callers should
@@ -440,22 +550,15 @@
440550 * @param targetClass The Java type the value should be converted to.
441551 * @return the value of the {@code i}th value converted to the given Java type.
442552 * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object.
443- * @throws com.datastax.driver.core.exceptions.CodecNotFoundException
444- * if no {@link TypeCodec} instance for {@code targetClass} could be found
445- * by the {@link CodecRegistry} currently in use.
553+ * @throws CodecNotFoundException if there is no registered codec to convert the element's CQL
554+ * type to {@code targetClass}.
446555 */
447556 <T> T get(int i, Class<T> targetClass);
448557
449558 /**
450559 * Returns the {@code i}th value converted to the given Java type.
451560 * <p>
452- * A suitable {@link TypeCodec} instance for the underlying CQL type and {@code targetType} must
453- * have been previously registered with the {@link CodecRegistry} currently in use.
454- * <p>
455- * This method should be used instead of {@link #getObject(int)} in cases
456- * where more than one codec is registered for the same CQL type; specifying the Java class
457- * allows the {@link CodecRegistry} to narrow down the search and return only an exactly-matching codec (if any),
458- * thus avoiding any risk of ambiguity.
561+ * This method uses the {@link CodecRegistry} to find a codec to convert the underlying CQL type to the given Java type.
459562 * <p>
460563 * Implementation note: the actual object returned by this method will depend
461564 * on the {@link TypeCodec codec} being used; therefore, callers should
@@ -468,17 +571,17 @@
468571 * @param targetType The Java type the value should be converted to.
469572 * @return the value of the {@code i}th value converted to the given Java type.
470573 * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object.
471- * @throws com.datastax.driver.core.exceptions.CodecNotFoundException
472- * if no {@link TypeCodec} instance for {@code targetType} could be found
473- * by the {@link CodecRegistry} currently in use.
574+ * @throws CodecNotFoundException if there is no registered codec to convert the element's CQL
575+ * type to {@code targetType}.
474576 */
475577 <T> T get(int i, TypeToken<T> targetType);
476578
477579 /**
478580 * Returns the {@code i}th value converted using the given {@link TypeCodec}.
479581 * <p>
480- * Note that this method allows to entirely bypass the {@link CodecRegistry} currently in use
481- * and forces the driver to use the given codec instead.
582+ * This method entirely bypasses the {@link CodecRegistry} and forces the driver to use the given codec instead.
583+ * This can be useful if the codec would collide with a previously registered one, or if you want to use the
584+ * codec just once without registering it.
482585 * <p>
483586 * It is the caller's responsibility to ensure that the given codec {@link TypeCodec#accepts(DataType) accepts}
484587 * the underlying CQL type; failing to do so may result in {@link InvalidTypeException}s being thrown.
modified driver-core/src/main/java/com/datastax/driver/core/GettableByNameData.java +149 −39
@@ -23,6 +23,7 @@
2323
2424 import com.google.common.reflect.TypeToken;
2525
26+import com.datastax.driver.core.exceptions.CodecNotFoundException;
2627 import com.datastax.driver.core.exceptions.InvalidTypeException;
2728
2829 /**
@@ -42,116 +43,172 @@
4243
4344 /**
4445 * Returns the value for {@code name} as a boolean.
46+ * <p>
47+ * This method uses the {@link CodecRegistry} to find a codec to convert the underlying CQL type to a Java {@code boolean}
48+ * (for CQL type {@code boolean}, this will be the built-in codec).
4549 *
4650 * @param name the name to retrieve.
47- * @return the boolean value for {@code name}. If the value is NULL,
48- * {@code false} is returned.
51+ * @return the boolean value for {@code name}. If the value is NULL, {@code false} is returned.
52+ * If you need to distinguish NULL and false values, check first with {@link #isNull(String)} or use {@code get(name, Boolean.class)}.
4953 *
5054 * @throws IllegalArgumentException if {@code name} is not valid name for this object.
55+ * @throws CodecNotFoundException if there is no registered codec to convert the underlying CQL
56+ * type to a boolean.
5157 */
5258 public boolean getBool(String name);
5359
5460 /**
5561 * Returns the value for {@code name} as a byte.
62+ * <p>
63+ * This method uses the {@link CodecRegistry} to find a codec to convert the underlying CQL type to a Java {@code byte}
64+ * (for CQL type {@code tinyint}, this will be the built-in codec).
5665 *
5766 * @param name the name to retrieve.
58- * @return the value for {@code name} as a byte. If the value is NULL,
67+ * @return the value for {@code name} as a byte. If the value is NULL, {@code 0} is returned.
68+ * If you need to distinguish NULL and 0, check first with {@link #isNull(String)} or use {@code get(name, Byte.class)}.
5969 * {@code 0} is returned.
6070 *
6171 * @throws IllegalArgumentException if {@code name} is not valid name for this object.
72+ * @throws CodecNotFoundException if there is no registered codec to convert the underlying CQL
73+ * type to a byte.
6274 */
6375 public byte getByte(String name);
6476
6577 /**
6678 * Returns the value for {@code name} as a short.
79+ * <p>
80+ * This method uses the {@link CodecRegistry} to find a codec to convert the underlying CQL type to a Java {@code short}
81+ * (for CQL type {@code smallint}, this will be the built-in codec).
6782 *
6883 * @param name the name to retrieve.
69- * @return the value for {@code name} as a short. If the value is NULL,
84+ * @return the value for {@code name} as a short. If the value is NULL, {@code 0} is returned.
85+ * If you need to distinguish NULL and 0, check first with {@link #isNull(String)} or use {@code get(name, Short.class)}.
7086 * {@code 0} is returned.
7187 *
7288 * @throws IllegalArgumentException if {@code name} is not valid name for this object.
89+ * @throws CodecNotFoundException if there is no registered codec to convert the underlying CQL
90+ * type to a short.
7391 */
7492 public short getShort(String name);
7593
7694 /**
7795 * Returns the value for {@code name} as an integer.
96+ * <p>
97+ * This method uses the {@link CodecRegistry} to find a codec to convert the underlying CQL type to a Java {@code int}
98+ * (for CQL type {@code int}, this will be the built-in codec).
7899 *
79100 * @param name the name to retrieve.
80- * @return the value for {@code name} as an integer. If the value is NULL,
101+ * @return the value for {@code name} as an integer. If the value is NULL, {@code 0} is returned.
102+ * If you need to distinguish NULL and 0, check first with {@link #isNull(String)} or use {@code get(name, Integer.class)}.
81103 * {@code 0} is returned.
82104 *
83105 * @throws IllegalArgumentException if {@code name} is not valid name for this object.
106+ * @throws CodecNotFoundException if there is no registered codec to convert the underlying CQL
107+ * type to an int.
84108 */
85109 public int getInt(String name);
86110
87111 /**
88112 * Returns the value for {@code name} as a long.
113+ * <p>
114+ * This method uses the {@link CodecRegistry} to find a codec to convert the underlying CQL type to a Java {@code byte}
115+ * (for CQL types {@code bigint} and {@code counter}, this will be the built-in codec).
89116 *
90117 * @param name the name to retrieve.
91- * @return the value for {@code name} as a long. If the value is NULL,
92- * {@code 0L} is returned.
118+ * @return the value for {@code name} as a long. If the value is NULL, {@code 0L} is returned.
119+ * If you need to distinguish NULL and 0L, check first with {@link #isNull(String)} or use {@code get(name, Long.class)}.
93120 *
94121 * @throws IllegalArgumentException if {@code name} is not valid name for this object.
122+ * @throws CodecNotFoundException if there is no registered codec to convert the underlying CQL
123+ * type to a long.
95124 */
96125 public long getLong(String name);
97126
98127 /**
99128 * Returns the value for {@code name} as a date.
129+ * <p>
130+ * This method uses the {@link CodecRegistry} to find a codec to convert the underlying CQL type to a {@code Date}
131+ * (for CQL type {@code timestamp}, this will be the built-in codec).
100132 *
101133 * @param name the name to retrieve.
102134 * @return the value for {@code name} as a date. If the value is NULL,
103135 * {@code null} is returned.
104136 *
105137 * @throws IllegalArgumentException if {@code name} is not valid name for this object.
138+ * @throws CodecNotFoundException if there is no registered codec to convert the underlying CQL
139+ * type to a {@code Date}.
106140 */
107141 public Date getTimestamp(String name);
108142
109143 /**
110144 * Returns the value for {@code name} as a date (without time).
145+ * <p>
146+ * This method uses the {@link CodecRegistry} to find a codec to convert the underlying CQL type to a {@link LocalDate}
147+ * (for CQL type {@code date}, this will be the built-in codec).
111148 *
112149 * @param name the name to retrieve.
113150 * @return the value for {@code name} as a date. If the value is NULL,
114151 * {@code null} is returned.
115152 *
116153 * @throws IllegalArgumentException if {@code name} is not valid name for this object.
154+ * @throws CodecNotFoundException if there is no registered codec to convert the underlying CQL
155+ * type to a {@code LocalDate}.
117156 */
118157 public LocalDate getDate(String name);
119158
120159 /**
121160 * Returns the value for {@code name} as a long in nanoseconds since midnight.
161+ * <p>
162+ * This method uses the {@link CodecRegistry} to find a codec to convert the underlying CQL type to a Java {@code long}
163+ * (for CQL type {@code time}, this will be the built-in codec).
122164 *
123165 * @param name the name to retrieve.
124166 * @return the value for {@code name} as a long. If the value is NULL,
125167 * {@code 0L} is returned.
126168 *
127169 * @throws IllegalArgumentException if {@code name} is not valid name for this object.
170+ * @throws CodecNotFoundException if there is no registered codec to convert the underlying CQL
171+ * type to a long.
128172 */
129173 public long getTime(String name);
130174
131175 /**
132176 * Returns the value for {@code name} as a float.
177+ * <p>
178+ * This method uses the {@link CodecRegistry} to find a codec to convert the underlying CQL type to a Java {@code float}
179+ * (for CQL type {@code float}, this will be the built-in codec).
133180 *
134181 * @param name the name to retrieve.
135- * @return the value for {@code name} as a float. If the value is NULL,
136- * {@code 0.0f} is returned.
182+ * @return the value for {@code name} as a float. If the value is NULL, {@code 0.0f} is returned.
183+ * If you need to distinguish NULL and 0.0f, check first with {@link #isNull(String)} or use {@code get(name, Float.class)}.
137184 *
138185 * @throws IllegalArgumentException if {@code name} is not valid name for this object.
186+ * @throws CodecNotFoundException if there is no registered codec to convert the underlying CQL
187+ * type to a float.
139188 */
140189 public float getFloat(String name);
141190
142191 /**
143192 * Returns the value for {@code name} as a double.
193+ * <p>
194+ * This method uses the {@link CodecRegistry} to find a codec to convert the underlying CQL type to a Java {@code double}
195+ * (for CQL type {@code double}, this will be the built-in codec).
144196 *
145197 * @param name the name to retrieve.
146- * @return the value for {@code name} as a double. If the value is NULL,
147- * {@code 0.0} is returned.
198+ * @return the value for {@code name} as a double. If the value is NULL, {@code 0.0} is returned.
199+ * If you need to distinguish NULL and 0.0, check first with {@link #isNull(String)} or use {@code get(name, Double.class)}.
148200 *
149201 * @throws IllegalArgumentException if {@code name} is not valid name for this object.
202+ * @throws CodecNotFoundException if there is no registered codec to convert the underlying CQL
203+ * type to a double.
150204 */
151205 public double getDouble(String name);
152206
153207 /**
154208 * Returns the value for {@code name} as a ByteBuffer.
209+ * <p>
210+ * This method does not use any codec; it returns a copy of the binary representation of the value. It is up to the
211+ * caller to convert the returned value appropriately.
155212 *
156213 * Note: this method always return the bytes composing the value, even if
157214 * the column is not of type BLOB. That is, this method never throw an
@@ -169,75 +226,104 @@
169226 /**
170227 * Returns the value for {@code name} as a byte array.
171228 * <p>
172- * Note that this method validate that the column is of type BLOB. If you want to retrieve
173- * the bytes for any type, use {@link #getBytesUnsafe(String)} instead.
229+ * This method uses the {@link CodecRegistry} to find a codec to convert the underlying CQL type to a Java {@code ByteBuffer}
230+ * (for CQL type {@code blob}, this will be the built-in codec).
174231 *
175232 * @param name the name to retrieve.
176233 * @return the value for {@code name} as a byte array. If the value is NULL,
177234 * {@code null} is returned.
178235 *
179236 * @throws IllegalArgumentException if {@code name} is not valid name for this object.
237+ * @throws CodecNotFoundException if there is no registered codec to convert the underlying CQL
238+ * type to a {@code ByteBuffer}.
180239 */
181240 public ByteBuffer getBytes(String name);
182241
183242 /**
184243 * Returns the value for {@code name} as a string.
244+ * <p>
245+ * This method uses the {@link CodecRegistry} to find a codec to convert the underlying CQL type to a Java string
246+ * (for CQL types {@code text}, {@code varchar} and {@code ascii}, this will be the built-in codec).
185247 *
186248 * @param name the name to retrieve.
187249 * @return the value for {@code name} as a string. If the value is NULL,
188250 * {@code null} is returned.
189251 *
190252 * @throws IllegalArgumentException if {@code name} is not valid name for this object.
253+ * @throws CodecNotFoundException if there is no registered codec to convert the underlying CQL
254+ * type to a string.
191255 */
192256 public String getString(String name);
193257
194258 /**
195259 * Returns the value for {@code name} as a variable length integer.
260+ * <p>
261+ * This method uses the {@link CodecRegistry} to find a codec to convert the underlying CQL type to a {@code BigInteger}
262+ * (for CQL type {@code varint}, this will be the built-in codec).
196263 *
197264 * @param name the name to retrieve.
198265 * @return the value for {@code name} as a variable length integer.
199266 * If the value is NULL, {@code null} is returned.
200267 *
201268 * @throws IllegalArgumentException if {@code name} is not valid name for this object.
269+ * @throws CodecNotFoundException if there is no registered codec to convert the underlying CQL
270+ * type to a {@code BigInteger}.
202271 */
203272 public BigInteger getVarint(String name);
204273
205274 /**
206275 * Returns the value for {@code name} as a variable length decimal.
276+ * <p>
277+ * This method uses the {@link CodecRegistry} to find a codec to convert the underlying CQL type to a {@code BigDecimal}
278+ * (for CQL type {@code decimal}, this will be the built-in codec).
207279 *
208280 * @param name the name to retrieve.
209281 * @return the value for {@code name} as a variable length decimal.
210282 * If the value is NULL, {@code null} is returned.
211283 *
212284 * @throws IllegalArgumentException if {@code name} is not valid name for this object.
285+ * @throws CodecNotFoundException if there is no registered codec to convert the underlying CQL
286+ * type to a {@code BigDecimal}.
213287 */
214288 public BigDecimal getDecimal(String name);
215289
216290 /**
217291 * Returns the value for {@code name} as a UUID.
292+ * <p>
293+ * This method uses the {@link CodecRegistry} to find a codec to convert the underlying CQL type to a {@code UUID}
294+ * (for CQL types {@code uuid} and {@code timeuuid}, this will be the built-in codec).
218295 *
219296 * @param name the name to retrieve.
220297 * @return the value for {@code name} as a UUID.
221298 * If the value is NULL, {@code null} is returned.
222299 *
223300 * @throws IllegalArgumentException if {@code name} is not valid name for this object.
301+ * @throws CodecNotFoundException if there is no registered codec to convert the underlying CQL
302+ * type to a {@code UUID}.
224303 */
225304 public UUID getUUID(String name);
226305
227306 /**
228307 * Returns the value for {@code name} as an InetAddress.
308+ * <p>
309+ * This method uses the {@link CodecRegistry} to find a codec to convert the underlying CQL type to an {@code InetAddress}
310+ * (for CQL type {@code inet}, this will be the built-in codec).
229311 *
230312 * @param name the name to retrieve.
231313 * @return the value for {@code name} as an InetAddress.
232314 * If the value is NULL, {@code null} is returned.
233315 *
234316 * @throws IllegalArgumentException if {@code name} is not valid name for this object.
317+ * @throws CodecNotFoundException if there is no registered codec to convert the underlying CQL
318+ * type to a {@code InetAddress}.
235319 */
236320 public InetAddress getInet(String name);
237321
238322 /**
239323 * Returns the value for {@code name} as a list.
240324 * <p>
325+ * This method uses the {@link CodecRegistry} to find a codec to convert the underlying CQL type to a list of the specified type.
326+ * <p>
241327 * If the type of the elements is generic, use {@link #getList(String, TypeToken)}.
242328 * <p>
243329 * Implementation note: the actual {@link List} implementation will depend
@@ -254,12 +340,16 @@
254340 * {@code T} objects.
255341 *
256342 * @throws IllegalArgumentException if {@code name} is not valid name for this object.
343+ * @throws CodecNotFoundException if there is no registered codec to convert the underlying CQL
344+ * type to a list.
257345 */
258346 public <T> List<T> getList(String name, Class<T> elementsClass);
259347
260348 /**
261349 * Returns the value for {@code name} as a list.
262350 * <p>
351+ * This method uses the {@link CodecRegistry} to find a codec to convert the underlying CQL type to a list of the specified type.
352+ * <p>
263353 * Use this variant with nested collections, which produce a generic element type:
264354 * <pre>
265355 * {@code List<List<String>> l = row.getList("theColumn", new TypeToken<List<String>>() {});}
@@ -279,12 +369,16 @@
279369 * {@code T} objects.
280370 *
281371 * @throws IllegalArgumentException if {@code name} is not valid name for this object.
372+ * @throws CodecNotFoundException if there is no registered codec to convert the underlying CQL
373+ * type to a list.
282374 */
283375 public <T> List<T> getList(String name, TypeToken<T> elementsType);
284376
285377 /**
286378 * Returns the value for {@code name} as a set.
287379 * <p>
380+ * This method uses the {@link CodecRegistry} to find a codec to convert the underlying CQL type to a set of the specified type.
381+ * <p>
288382 * If the type of the elements is generic, use {@link #getSet(String, TypeToken)}.
289383 * <p>
290384 * Implementation note: the actual {@link Set} implementation will depend
@@ -301,12 +395,16 @@
301395 * {@code T} objects.
302396 *
303397 * @throws IllegalArgumentException if {@code name} is not valid name for this object.
398+ * @throws CodecNotFoundException if there is no registered codec to convert the underlying CQL
399+ * type to a set.
304400 */
305401 public <T> Set<T> getSet(String name, Class<T> elementsClass);
306402
307403 /**
308404 * Returns the value for {@code name} as a set.
309405 * <p>
406+ * This method uses the {@link CodecRegistry} to find a codec to convert the underlying CQL type to a set of the specified type.
407+ * <p>
310408 * Use this variant with nested collections, which produce a generic element type:
311409 * <pre>
312410 * {@code Set<List<String>> l = row.getSet("theColumn", new TypeToken<List<String>>() {});}
@@ -326,12 +424,16 @@
326424 * {@code T} objects.
327425 *
328426 * @throws IllegalArgumentException if {@code name} is not valid name for this object.
427+ * @throws CodecNotFoundException if there is no registered codec to convert the underlying CQL
428+ * type to a set.
329429 */
330430 public <T> Set<T> getSet(String name, TypeToken<T> elementsType);
331431
332432 /**
333433 * Returns the value for {@code name} as a map.
334434 * <p>
435+ * This method uses the {@link CodecRegistry} to find a codec to convert the underlying CQL type to a map of the specified types.
436+ * <p>
335437 * If the type of the keys and/or values is generic, use {@link #getMap(String, TypeToken, TypeToken)}.
336438 * <p>
337439 * Implementation note: the actual {@link Map} implementation will depend
@@ -349,12 +451,16 @@
349451 * {@code K} to {@code V} objects.
350452 *
351453 * @throws IllegalArgumentException if {@code name} is not valid name for this object.
454+ * @throws CodecNotFoundException if there is no registered codec to convert the underlying CQL
455+ * type to a map.
352456 */
353457 public <K, V> Map<K, V> getMap(String name, Class<K> keysClass, Class<V> valuesClass);
354458
355459 /**
356460 * Returns the value for {@code name} as a map.
357461 * <p>
462+ * This method uses the {@link CodecRegistry} to find a codec to convert the underlying CQL type to a map of the specified types.
463+ * <p>
358464 * Use this variant with nested collections, which produce a generic element type:
359465 * <pre>
360466 * {@code Map<Int, List<String>> l = row.getMap("theColumn", TypeToken.of(Integer.class), new TypeToken<List<String>>() {});}
@@ -375,40 +481,53 @@
375481 * {@code K} to {@code V} objects.
376482 *
377483 * @throws IllegalArgumentException if {@code name} is not valid name for this object.
484+ * @throws CodecNotFoundException if there is no registered codec to convert the underlying CQL
485+ * type to a map.
378486 */
379487 public <K, V> Map<K, V> getMap(String name, TypeToken<K> keysType, TypeToken<V> valuesType);
380488
381489 /**
382490 * Return the value for {@code name} as a UDT value.
491+ * <p>
492+ * This method uses the {@link CodecRegistry} to find a codec to convert the underlying CQL type to a {@code UDTValue}
493+ * (if the CQL type is a UDT, the registry will generate a codec automatically).
383494 *
384495 * @param name the name to retrieve.
385496 * @return the value of {@code name} as a UDT value. If the value is NULL,
386497 * then {@code null} will be returned.
387498 *
388499 * @throws IllegalArgumentException if {@code name} is not valid name for this object.
500+ * @throws CodecNotFoundException if there is no registered codec to convert the underlying CQL
501+ * type to a {@code UDTValue}.
389502 */
390503 public UDTValue getUDTValue(String name);
391504
392505 /**
393506 * Return the value for {@code name} as a tuple value.
507+ * <p>
508+ * This method uses the {@link CodecRegistry} to find a codec to convert the underlying CQL type to a {@code TupleValue}
509+ * (if the CQL type is a tuple, the registry will generate a codec automatically).
394510 *
395511 * @param name the name to retrieve.
396512 * @return the value of {@code name} as a tuple value. If the value is NULL,
397513 * then {@code null} will be returned.
398514 *
399515 * @throws IllegalArgumentException if {@code name} is not valid name for this object.
516+ * @throws CodecNotFoundException if there is no registered codec to convert the underlying CQL
517+ * type to a {@code TupleValue}.
400518 */
401519 public TupleValue getTupleValue(String name);
402520
403521 /**
404522 * Returns the value for {@code name} as the Java type matching its CQL type.
405523 * <p>
406- * Note: if two or more codecs are available
407- * for the underlying CQL type, <em>the one that will be used will be
408- * the first one to be registered.</em>.
524+ * This method uses the {@link CodecRegistry} to find the first codec that handles the underlying CQL type. The Java type
525+ * of the returned object will be determined by the codec that was selected.
409526 * <p>
410- * For these reasons, it is generally preferable to use the more
411- * deterministic methods {@link #get(String, Class)} or {@link #get(String, TypeToken)} instead.
527+ * Use this method to dynamically inspect elements when types aren't known in advance, for instance if you're writing a
528+ * generic row logger. If you know the target Java type, it is generally preferable to use typed getters, such as the
529+ * ones for built-in types ({@link #getBool(String)}, {@link #getInt(String)}, etc.), or {@link #get(String, Class)} and
530+ * {@link #get(String, TypeToken)} for custom types.
412531 *
413532 * @param name the name to retrieve.
414533 * @return the value of {@code name} as the Java type matching its CQL type.
@@ -416,19 +535,17 @@
416535 * If it is NULL and is a collection type, an empty (immutable) collection is returned.
417536 *
418537 * @throws IllegalArgumentException if {@code name} is not a valid name for this object.
538+ *
539+ * @see CodecRegistry#codecFor(DataType)
419540 */
420541 Object getObject(String name);
421542
422543 /**
423544 * Returns the value for {@code name} converted to the given Java type.
424545 * <p>
425- * A suitable {@link TypeCodec} instance for for the underlying CQL type and {@code targetClass} must
426- * have been previously registered with the {@link CodecRegistry} currently in use.
546+ * This method uses the {@link CodecRegistry} to find a codec to convert the underlying CQL type to the given Java type.
427547 * <p>
428- * This method should be used instead of {@link #getObject(String)} in cases
429- * where more than one codec is registered for the same CQL type; specifying the Java class
430- * allows the {@link CodecRegistry} to narrow down the search and return only an exactly-matching codec (if any),
431- * thus avoiding any risk of ambiguity.
548+ * If the target type is generic, use {@link #get(String, TypeToken)}.
432549 * <p>
433550 * Implementation note: the actual object returned by this method will depend
434551 * on the {@link TypeCodec codec} being used; therefore, callers should
@@ -441,22 +558,15 @@
441558 * @param targetClass The Java type the value should be converted to.
442559 * @return the value for {@code name} value converted to the given Java type.
443560 * @throws IllegalArgumentException if {@code name} is not a valid name for this object.
444- * @throws com.datastax.driver.core.exceptions.CodecNotFoundException
445- * if no {@link TypeCodec} instance for {@code targetClass} could be found
446- * by the {@link CodecRegistry} currently in use.
561+ * @throws CodecNotFoundException if there is no registered codec to convert the underlying CQL
562+ * type to {@code targetClass}.
447563 */
448564 <T> T get(String name, Class<T> targetClass);
449565
450566 /**
451567 * Returns the value for {@code name} converted to the given Java type.
452568 * <p>
453- * A suitable {@link TypeCodec} instance for for the underlying CQL type and {@code targetType} must
454- * have been previously registered with the {@link CodecRegistry} currently in use.
455- * <p>
456- * This method should be used instead of {@link #getObject(String)} in cases
457- * where more than one codec is registered for the same CQL type; specifying the Java class
458- * allows the {@link CodecRegistry} to narrow down the search and return only an exactly-matching codec (if any),
459- * thus avoiding any risk of ambiguity.
569+ * This method uses the {@link CodecRegistry} to find a codec to convert the underlying CQL type to the given Java type.
460570 * <p>
461571 * Implementation note: the actual object returned by this method will depend
462572 * on the {@link TypeCodec codec} being used; therefore, callers should
@@ -469,17 +579,17 @@
469579 * @param targetType The Java type the value should be converted to.
470580 * @return the value for {@code name} value converted to the given Java type.
471581 * @throws IllegalArgumentException if {@code name} is not a valid name for this object.
472- * @throws com.datastax.driver.core.exceptions.CodecNotFoundException
473- * if no {@link TypeCodec} instance for {@code targetType} could be found
474- * by the {@link CodecRegistry} currently in use.
582+ * @throws CodecNotFoundException if there is no registered codec to convert the underlying CQL
583+ * type to {@code targetType}.
475584 */
476585 <T> T get(String name, TypeToken<T> targetType);
477586
478587 /**
479588 * Returns the value for {@code name} converted using the given {@link TypeCodec}.
480589 * <p>
481- * Note that this method allows to entirely bypass the {@link CodecRegistry} currently in use
482- * and forces the driver to use the given codec instead.
590+ * This method entirely bypasses the {@link CodecRegistry} and forces the driver to use the given codec instead.
591+ * This can be useful if the codec would collide with a previously registered one, or if you want to use the
592+ * codec just once without registering it.
483593 * <p>
484594 * It is the caller's responsibility to ensure that the given codec {@link TypeCodec#accepts(DataType) accepts}
485595 * the underlying CQL type; failing to do so may result in {@link InvalidTypeException}s being thrown.
modified driver-core/src/main/java/com/datastax/driver/core/SettableByIndexData.java +187 −90
@@ -23,6 +23,7 @@
2323
2424 import com.google.common.reflect.TypeToken;
2525
26+import com.datastax.driver.core.exceptions.CodecNotFoundException;
2627 import com.datastax.driver.core.exceptions.InvalidTypeException;
2728
2829 /**
@@ -32,146 +33,209 @@
3233
3334 /**
3435 * Sets the {@code i}th value to the provided boolean.
36+ * <p>
37+ * This method uses the {@link CodecRegistry} to find a codec to handle the conversion
38+ * to the underlying CQL type (for CQL type {@code boolean}, this will be the built-in codec).
3539 *
3640 * @param i the index of the value to set.
37- * @param v the value to set.
41+ * @param v the value to set. To set the value to NULL, use {@link #setToNull(int)} or
42+ * {@code set(i, v, Boolean.class)}
3843 * @return this object.
3944 *
4045 * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object.
46+ * @throws CodecNotFoundException if there is no registered codec to convert the value to the
47+ * underlying CQL type.
4148 */
4249 public T setBool(int i, boolean v);
4350
4451 /**
4552 * Set the {@code i}th value to the provided byte.
53+ * <p>
54+ * This method uses the {@link CodecRegistry} to find a codec to handle the conversion
55+ * to the underlying CQL type (for CQL type {@code tinyint}, this will be the built-in codec).
4656 *
4757 * @param i the index of the value to set.
48- * @param v the value to set.
58+ * @param v the value to set. To set the value to NULL, use {@link #setToNull(int)} or
59+ * {@code set(i, v, Byte.class)}
4960 * @return this object.
5061 *
5162 * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object.
63+ * @throws CodecNotFoundException if there is no registered codec to convert the value to the
64+ * underlying CQL type.
5265 */
5366 public T setByte(int i, byte v);
5467
5568 /**
5669 * Set the {@code i}th value to the provided short.
70+ * <p>
71+ * This method uses the {@link CodecRegistry} to find a codec to handle the conversion
72+ * to the underlying CQL type (for CQL type {@code smallint}, this will be the built-in codec).
5773 *
5874 * @param i the index of the value to set.
59- * @param v the value to set.
75+ * @param v the value to set. To set the value to NULL, use {@link #setToNull(int)} or
76+ * {@code set(i, v, Short.class)}
6077 * @return this object.
6178 *
6279 * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object.
80+ * @throws CodecNotFoundException if there is no registered codec to convert the value to the
81+ * underlying CQL type.
6382 */
6483 public T setShort(int i, short v);
6584
6685 /**
6786 * Set the {@code i}th value to the provided integer.
87+ * <p>
88+ * This method uses the {@link CodecRegistry} to find a codec to handle the conversion
89+ * to the underlying CQL type (for CQL type {@code int}, this will be the built-in codec).
6890 *
6991 * @param i the index of the value to set.
70- * @param v the value to set.
92+ * @param v the value to set. To set the value to NULL, use {@link #setToNull(int)} or
93+ * {@code set(i, v, Integer.class)}
7194 * @return this object.
7295 *
7396 * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object.
97+ * @throws CodecNotFoundException if there is no registered codec to convert the value to the
98+ * underlying CQL type.
7499 */
75100 public T setInt(int i, int v);
76101
77102 /**
78103 * Sets the {@code i}th value to the provided long.
104+ * <p>
105+ * This method uses the {@link CodecRegistry} to find a codec to handle the conversion
106+ * to the underlying CQL type (for CQL type {@code bigint}, this will be the built-in codec).
79107 *
80108 * @param i the index of the value to set.
81- * @param v the value to set.
109+ * @param v the value to set. To set the value to NULL, use {@link #setToNull(int)} or
110+ * {@code set(i, v, Long.class)}
82111 * @return this object.
83112 *
84113 * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object.
114+ * @throws CodecNotFoundException if there is no registered codec to convert the value to the
115+ * underlying CQL type.
85116 */
86117 public T setLong(int i, long v);
87118
88119 /**
89120 * Set the {@code i}th value to the provided date.
121+ * <p>
122+ * This method uses the {@link CodecRegistry} to find a codec to handle the conversion
123+ * to the underlying CQL type (for CQL type {@code timestamp}, this will be the built-in codec).
90124 *
91125 * @param i the index of the value to set.
92126 * @param v the value to set.
93127 * @return this object.
94128 *
95129 * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object.
130+ * @throws CodecNotFoundException if there is no registered codec to convert the value to the
131+ * underlying CQL type.
96132 */
97133 public T setTimestamp(int i, Date v);
98134
99135 /**
100136 * Set the {@code i}th value to the provided date (without time).
137+ * <p>
138+ * This method uses the {@link CodecRegistry} to find a codec to handle the conversion
139+ * to the underlying CQL type (for CQL type {@code date}, this will be the built-in codec).
101140 *
102141 * @param i the index of the value to set.
103142 * @param v the value to set.
104143 * @return this object.
105144 *
106145 * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object.
146+ * @throws CodecNotFoundException if there is no registered codec to convert the value to the
147+ * underlying CQL type.
107148 */
108149 public T setDate(int i, LocalDate v);
109150
110151 /**
111152 * Set the {@code i}th value to the provided time as a long in nanoseconds since midnight.
153+ * <p>
154+ * This method uses the {@link CodecRegistry} to find a codec to handle the conversion
155+ * to the underlying CQL type (for CQL type {@code time}, this will be the built-in codec).
112156 *
113157 * @param i the index of the value to set.
114158 * @param v the value to set.
115159 * @return this object.
116160 *
117161 * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object.
162+ * @throws CodecNotFoundException if there is no registered codec to convert the value to the
163+ * underlying CQL type.
118164 */
119165 public T setTime(int i, long v);
120166
121167 /**
122168 * Sets the {@code i}th value to the provided float.
169+ * <p>
170+ * This method uses the {@link CodecRegistry} to find a codec to handle the conversion
171+ * to the underlying CQL type (for CQL type {@code float}, this will be the built-in codec).
123172 *
124173 * @param i the index of the value to set.
125- * @param v the value to set.
174+ * @param v the value to set. To set the value to NULL, use {@link #setToNull(int)} or
175+ * {@code set(i, v, Float.class)}
126176 * @return this object.
127177 *
128178 * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object.
179+ * @throws CodecNotFoundException if there is no registered codec to convert the value to the
180+ * underlying CQL type.
129181 */
130182 public T setFloat(int i, float v);
131183
132184 /**
133185 * Sets the {@code i}th value to the provided double.
186+ * <p>
187+ * This method uses the {@link CodecRegistry} to find a codec to handle the conversion
188+ * to the underlying CQL type (for CQL type {@code double}, this will be the built-in codec).
134189 *
135190 * @param i the index of the value to set.
136- * @param v the value to set.
191+ * @param v the value to set. To set the value to NULL, use {@link #setToNull(int)} or
192+ * {@code set(i, v, Double.class)}.
137193 * @return this object.
138194 *
139195 * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object.
196+ * @throws CodecNotFoundException if there is no registered codec to convert the value to the
197+ * underlying CQL type.
140198 */
141199 public T setDouble(int i, double v);
142200
143201 /**
144202 * Sets the {@code i}th value to the provided string.
203+ * <p>
204+ * This method uses the {@link CodecRegistry} to find a codec to handle the conversion
205+ * to the underlying CQL type (for CQL types {@code text}, {@code varchar} and {@code ascii},
206+ * this will be the built-in codec).
145207 *
146208 * @param i the index of the value to set.
147209 * @param v the value to set.
148210 * @return this object.
149211 *
150212 * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object.
213+ * @throws CodecNotFoundException if there is no registered codec to convert the value to the
214+ * underlying CQL type.
151215 */
152216 public T setString(int i, String v);
153217
154218 /**
155219 * Sets the {@code i}th value to the provided byte buffer.
156- *
157- * This method validate that the type of the column set is BLOB. If you
158- * want to insert manually serialized data into columns of another type,
159- * use {@link #setBytesUnsafe} instead.
220+ * <p>
221+ * This method uses the {@link CodecRegistry} to find a codec to handle the conversion
222+ * to the underlying CQL type (for CQL type {@code blob}, this will be the built-in codec).
160223 *
161224 * @param i the index of the value to set.
162225 * @param v the value to set.
163226 * @return this object.
164227 *
165228 * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object.
229+ * @throws CodecNotFoundException if there is no registered codec to convert the value to the
230+ * underlying CQL type.
166231 */
167232 public T setBytes(int i, ByteBuffer v);
168233
169234 /**
170235 * Sets the {@code i}th value to the provided byte buffer.
171- *
172- * Contrary to {@link #setBytes}, this method does not check the
173- * type of the column set. If you insert data that is not compatible with
174- * the type of the column, you will get an {@code InvalidQueryException} at
236+ * <p>
237+ * This method does not use any codec; it sets the value in its binary form directly. If you insert
238+ * data that is not compatible with the underlying CQL type, you will get an {@code InvalidQueryException} at
175239 * execute time.
176240 *
177241 * @param i the index of the value to set.
@@ -184,148 +248,165 @@
184248
185249 /**
186250 * Sets the {@code i}th value to the provided big integer.
251+ * <p>
252+ * This method uses the {@link CodecRegistry} to find a codec to handle the conversion
253+ * to the underlying CQL type (for CQL type {@code varint}, this will be the built-in codec).
187254 *
188255 * @param i the index of the value to set.
189256 * @param v the value to set.
190257 * @return this object.
191258 *
192259 * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object.
260+ * @throws CodecNotFoundException if there is no registered codec to convert the value to the
261+ * underlying CQL type.
193262 */
194263 public T setVarint(int i, BigInteger v);
195264
196265 /**
197266 * Sets the {@code i}th value to the provided big decimal.
267+ * <p>
268+ * This method uses the {@link CodecRegistry} to find a codec to handle the conversion
269+ * to the underlying CQL type (for CQL type {@code decimal}, this will be the built-in codec).
198270 *
199271 * @param i the index of the value to set.
200272 * @param v the value to set.
201273 * @return this object.
202274 *
203275 * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object.
276+ * @throws CodecNotFoundException if there is no registered codec to convert the value to the
277+ * underlying CQL type.
204278 */
205279 public T setDecimal(int i, BigDecimal v);
206280
207281 /**
208282 * Sets the {@code i}th value to the provided UUID.
283+ * <p>
284+ * This method uses the {@link CodecRegistry} to find a codec to handle the conversion
285+ * to the underlying CQL type (for CQL types {@code uuid} and {@code timeuuid}, this will
286+ * be the built-in codec).
209287 *
210288 * @param i the index of the value to set.
211289 * @param v the value to set.
212290 * @return this object.
213291 *
214292 * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object.
293+ * @throws CodecNotFoundException if there is no registered codec to convert the value to the
294+ * underlying CQL type.
215295 */
216296 public T setUUID(int i, UUID v);
217297
218298 /**
219299 * Sets the {@code i}th value to the provided inet address.
300+ * <p>
301+ * This method uses the {@link CodecRegistry} to find a codec to handle the conversion
302+ * to the underlying CQL type (for CQL type {@code inet}, this will be the built-in codec).
220303 *
221304 * @param i the index of the value to set.
222305 * @param v the value to set.
223306 * @return this object.
224307 *
225308 * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object.
309+ * @throws CodecNotFoundException if there is no registered codec to convert the value to the
310+ * underlying CQL type.
226311 */
227312 public T setInet(int i, InetAddress v);
228313
229314 /**
230315 * Sets the {@code i}th value to the provided list.
231316 * <p>
232- * Please note that {@code null} values inside collections are not supported by CQL.
233- * <p>
234- * Note: if two or more codecs are available
235- * for the underlying CQL type, <em>the one that will be used will be
236- * the first one to be registered.</em>.
237- * <p>
238- * For these reasons, it is generally preferable to use the more
239- * deterministic methods {@link #setList(int, List, Class)} or
240- * {@link #setList(int, List, TypeToken)}.
317+ * This method uses the {@link CodecRegistry} to find a codec to handle the conversion
318+ * to the underlying CQL type (the type of the elements in the Java list is not considered).
319+ * If two or more codecs target that CQL type, the one that was first registered will be used.
320+ * For this reason, it is generally preferable to use the more deterministic methods
321+ * {@link #setList(int, List, Class)} or {@link #setList(int, List, TypeToken)}.
241322 *
242323 * @param i the index of the value to set.
243- * @param v the value to set.
324+ * @param v the value to set. Note that {@code null} values inside collections are not supported by CQL.
244325 * @return this object.
245326 *
246327 * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object.
247328 * @throws NullPointerException if {@code v} contains null values. Nulls are not supported in collections
248329 * by CQL.
330+ * @throws CodecNotFoundException if there is no registered codec to convert the value to the
331+ * underlying CQL type.
249332 */
250333 public <E> T setList(int i, List<E> v);
251334
252335 /**
253- * Sets the {@code i}th value to the provided list, whose elements are of the provided
336+ * Sets the {@code i}th value to the provided list, which elements are of the provided
254337 * Java class.
255338 * <p>
256- * Please note that {@code null} values inside collections are not supported by CQL.
339+ * This method uses the {@link CodecRegistry} to find a codec to handle the conversion of lists of the given
340+ * Java type to the underlying CQL type.
257341 * <p>
258- * Note about performance: this method is able to cache codecs used to serialize the list elements,
259- * and thus should be used instead of {@link #setList(int, List)}
260- * whenever possible, because it performs significantly better.
342+ * If the type of the elements is generic, use {@link #setList(int, List, TypeToken)}.
261343 *
262344 * @param i the index of the value to set.
263- * @param v the value to set.
345+ * @param v the value to set. Note that {@code null} values inside collections are not supported by CQL.
264346 * @param elementsClass the class for the elements of the list.
265347 * @return this object.
266348 *
267349 * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object.
268350 * @throws NullPointerException if {@code v} contains null values. Nulls are not supported in collections
269351 * by CQL.
352+ * @throws CodecNotFoundException if there is no registered codec to convert the value to the
353+ * underlying CQL type.
270354 */
271355 public <E> T setList(int i, List<E> v, Class<E> elementsClass);
272356
273357 /**
274- * Sets the {@code i}th value to the provided list, whose elements are of the provided
358+ * Sets the {@code i}th value to the provided list, which elements are of the provided
275359 * Java type.
276360 * <p>
277- * Please note that {@code null} values inside collections are not supported by CQL.
278- * <p>
279- * Note about performance: this method is able to cache codecs used to serialize the list elements,
280- * and thus should be used instead of {@link #setList(int, List)}
281- * whenever possible, because it performs significantly better.
361+ * This method uses the {@link CodecRegistry} to find a codec to handle the conversion of lists of the given
362+ * Java type to the underlying CQL type.
282363 *
283364 * @param i the index of the value to set.
284- * @param v the value to set.
365+ * @param v the value to set. Note that {@code null} values inside collections are not supported by CQL.
285366 * @param elementsType the type for the elements of the list.
286367 * @return this object.
287368 *
288369 * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object.
289370 * @throws NullPointerException if {@code v} contains null values. Nulls are not supported in collections
290371 * by CQL.
372+ * @throws CodecNotFoundException if there is no registered codec to convert the value to the
373+ * underlying CQL type.
291374 */
292375 public <E> T setList(int i, List<E> v, TypeToken<E> elementsType);
293376
294377 /**
295378 * Sets the {@code i}th value to the provided map.
296379 * <p>
297- * Please note that {@code null} values are not supported inside collection by CQL.
298- * <p>
299- * Note: if two or more codecs are available
300- * for the underlying CQL type, <em>the one that will be used will be
301- * the first one to be registered.</em>.
302- * <p>
303- * For these reasons, it is generally preferable to use the more
304- * deterministic methods {@link #setMap(int, Map, Class, Class)} or
305- * {@link #setMap(int, Map, TypeToken, TypeToken)}.
380+ * This method uses the {@link CodecRegistry} to find a codec to handle the conversion
381+ * to the underlying CQL type (the type of the elements in the Java map is not considered).
382+ * If two or more codecs target that CQL type, the one that was first registered will be used.
383+ * For this reason, it is generally preferable to use the more deterministic methods
384+ * {@link #setMap(int, Map, Class, Class)} or {@link #setMap(int, Map, TypeToken, TypeToken)}.
306385 *
307386 * @param i the index of the value to set.
308- * @param v the value to set.
387+ * @param v the value to set. Note that {@code null} values inside collections are not supported by CQL.
388+ * @return this object.
309389 * @return this object.
310390 *
311391 * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object.
312392 * @throws NullPointerException if {@code v} contains null values. Nulls are not supported in collections
313393 * by CQL.
394+ * @throws CodecNotFoundException if there is no registered codec to convert the value to the
395+ * underlying CQL type.
314396 */
315397 public <K, V> T setMap(int i, Map<K, V> v);
316398
317399 /**
318- * Sets the {@code i}th value to the provided map, whose keys and values are of the provided
400+ * Sets the {@code i}th value to the provided map, which keys and values are of the provided
319401 * Java classes.
320402 * <p>
321- * Please note that {@code null} values inside collections are not supported by CQL.
403+ * This method uses the {@link CodecRegistry} to find a codec to handle the conversion of lists of the given
404+ * Java types to the underlying CQL type.
322405 * <p>
323- * Note about performance: this method is able to cache codecs used to serialize the map entries,
324- * and thus should be used instead of {@link #setMap(int, Map)}
325- * whenever possible, because it performs significantly better.
406+ * If the type of the keys or values is generic, use {@link #setMap(int, Map, TypeToken, TypeToken)}.
326407 *
327408 * @param i the index of the value to set.
328- * @param v the value to set.
409+ * @param v the value to set. Note that {@code null} values inside collections are not supported by CQL.
329410 * @param keysClass the class for the keys of the map.
330411 * @param valuesClass the class for the values of the map.
331412 * @return this object.
@@ -333,21 +414,20 @@
333414 * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object.
334415 * @throws NullPointerException if {@code v} contains null values. Nulls are not supported in collections
335416 * by CQL.
417+ * @throws CodecNotFoundException if there is no registered codec to convert the value to the
418+ * underlying CQL type.
336419 */
337420 public <K, V> T setMap(int i, Map<K, V> v, Class<K> keysClass, Class<V> valuesClass);
338421
339422 /**
340- * Sets the {@code i}th value to the provided map, whose keys and values are of the provided
423+ * Sets the {@code i}th value to the provided map, which keys and values are of the provided
341424 * Java types.
342425 * <p>
343- * Please note that {@code null} values inside collections are not supported by CQL.
344- * <p>
345- * Note about performance: this method is able to cache codecs used to serialize the map entries,
346- * and thus should be used instead of {@link #setMap(int, Map)}
347- * whenever possible, because it performs significantly better.
426+ * This method uses the {@link CodecRegistry} to find a codec to handle the conversion of lists of the given
427+ * Java types to the underlying CQL type.
348428 *
349429 * @param i the index of the value to set.
350- * @param v the value to set.
430+ * @param v the value to set. Note that {@code null} values inside collections are not supported by CQL.
351431 * @param keysType the type for the keys of the map.
352432 * @param valuesType the type for the values of the map.
353433 * @return this object.
@@ -355,93 +435,103 @@
355435 * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object.
356436 * @throws NullPointerException if {@code v} contains null values. Nulls are not supported in collections
357437 * by CQL.
438+ * @throws CodecNotFoundException if there is no registered codec to convert the value to the
439+ * underlying CQL type.
358440 */
359441 public <K, V> T setMap(int i, Map<K, V> v, TypeToken<K> keysType, TypeToken<V> valuesType);
360442
361443 /**
362444 * Sets the {@code i}th value to the provided set.
363445 * <p>
364- * Please note that {@code null} values are not supported inside collection by CQL.
365- * <p>
366- * Note: if two or more codecs are available
367- * for the underlying CQL type, <em>the one that will be used will be
368- * the first one to be registered.</em>.
369- * <p>
370- * For these reasons, it is generally preferable to use the more
371- * deterministic methods {@link #setSet(int, Set, Class)} or
372- * {@link #setSet(int, Set, TypeToken)}.
446+ * This method uses the {@link CodecRegistry} to find a codec to handle the conversion
447+ * to the underlying CQL type (the type of the elements in the Java set is not considered).
448+ * If two or more codecs target that CQL type, the one that was first registered will be used.
449+ * For this reason, it is generally preferable to use the more deterministic methods
450+ * {@link #setSet(int, Set, Class)} or {@link #setSet(int, Set, TypeToken)}.
373451 *
374452 * @param i the index of the value to set.
375- * @param v the value to set.
453+ * @param v the value to set. Note that {@code null} values inside collections are not supported by CQL.
376454 * @return this object.
377455 *
378456 * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object.
379457 * @throws NullPointerException if {@code v} contains null values. Nulls are not supported in collections
380458 * by CQL.
459+ * @throws CodecNotFoundException if there is no registered codec to convert the value to the
460+ * underlying CQL type.
381461 */
382462 public <E> T setSet(int i, Set<E> v);
383463
384464 /**
385- * Sets the {@code i}th value to the provided set, whose elements are of the provided
465+ * Sets the {@code i}th value to the provided set, which elements are of the provided
386466 * Java class.
387467 * <p>
388- * Please note that {@code null} values inside collections are not supported by CQL.
468+ * This method uses the {@link CodecRegistry} to find a codec to handle the conversion of sets of the given
469+ * Java type to the underlying CQL type.
389470 * <p>
390- * Note about performance: this method is able to cache codecs used to serialize the set elements,
391- * and thus should be used instead of {@link #setSet(int, Set)}
392- * whenever possible, because it performs significantly better.
471+ * If the type of the elements is generic, use {@link #setSet(int, Set, TypeToken)}.
393472 *
394473 * @param i the index of the value to set.
395- * @param v the value to set.
474+ * @param v the value to set. Note that {@code null} values inside collections are not supported by CQL.
396475 * @param elementsClass the class for the elements of the set.
397476 * @return this object.
398477 *
399478 * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object.
400479 * @throws NullPointerException if {@code v} contains null values. Nulls are not supported in collections
401480 * by CQL.
481+ * @throws CodecNotFoundException if there is no registered codec to convert the value to the
482+ * underlying CQL type.
402483 */
403484 public <E> T setSet(int i, Set<E> v, Class<E> elementsClass);
404485
405486 /**
406- * Sets the {@code i}th value to the provided set, whose elements are of the provided
487+ * Sets the {@code i}th value to the provided set, which elements are of the provided
407488 * Java type.
408489 * <p>
409- * Please note that {@code null} values inside collections are not supported by CQL.
410- * <p>
411- * Note about performance: this method is able to cache codecs used to serialize the set elements,
412- * and thus should be used instead of {@link #setSet(int, Set)}
413- * whenever possible, because it performs significantly better.
490+ * This method uses the {@link CodecRegistry} to find a codec to handle the conversion of sets of the given
491+ * Java type to the underlying CQL type.
414492 *
415493 * @param i the index of the value to set.
416- * @param v the value to set.
494+ * @param v the value to set. Note that {@code null} values inside collections are not supported by CQL.
417495 * @param elementsType the type for the elements of the set.
418496 * @return this object.
419497 *
420498 * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object.
421499 * @throws NullPointerException if {@code v} contains null values. Nulls are not supported in collections
422500 * by CQL.
501+ * @throws CodecNotFoundException if there is no registered codec to convert the value to the
502+ * underlying CQL type.
423503 */
424504 public <E> T setSet(int i, Set<E> v, TypeToken<E> elementsType);
425505
426506 /**
427507 * Sets the {@code i}th value to the provided UDT value.
508+ * <p>
509+ * This method uses the {@link CodecRegistry} to find a codec to handle the conversion of {@code UDTValue}
510+ * to the underlying CQL type.
428511 *
429512 * @param i the index of the value to set.
430513 * @param v the value to set.
431514 * @return this object.
432515 *
433516 * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object.
517+ * @throws CodecNotFoundException if there is no registered codec to convert the value to the
518+ * underlying CQL type.
434519 */
435520 public T setUDTValue(int i, UDTValue v);
436521
437522 /**
438523 * Sets the {@code i}th value to the provided tuple value.
524+ * <p>
525+ * This method uses the {@link CodecRegistry} to find a codec to handle the conversion of {@code TupleValue}
526+ * to the underlying CQL type.
439527 *
440528 * @param i the index of the value to set.
441529 * @param v the value to set.
442530 * @return this object.
443531 *
444532 * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object.
533+ * @throws CodecNotFoundException if there is no registered codec to convert the value to the
534+ * underlying CQL type.
445535 */
446536 public T setTupleValue(int i, TupleValue v);
447537
@@ -459,36 +549,43 @@
459549 /**
460550 * Sets the {@code i}th value to the provided value of the provided Java class.
461551 * <p>
462- * A suitable {@link TypeCodec} instance for the underlying CQL type and the provided class must
463- * have been previously registered with the {@link CodecRegistry} currently in use.
552+ * This method uses the {@link CodecRegistry} to find a codec to handle the conversion of the provided Java class
553+ * to the underlying CQL type.
554+ * <p>
555+ * If the Java type is generic, use {@link #set(int, Object, TypeToken)} instead.
464556 *
465557 * @param i the index of the value to set.
466558 * @param v the value to set; may be {@code null}.
467559 * @param targetClass The Java class to convert to; must not be {@code null};
468560 * @return this object.
469561 * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object.
562+ * @throws CodecNotFoundException if there is no registered codec to convert the value to the
563+ * underlying CQL type.
470564 */
471565 <V> T set(int i, V v, Class<V> targetClass);
472566
473567 /**
474568 * Sets the {@code i}th value to the provided value of the provided Java type.
475569 * <p>
476- * A suitable {@link TypeCodec} instance for the underlying CQL type and the provided class must
477- * have been previously registered with the {@link CodecRegistry} currently in use.
570+ * This method uses the {@link CodecRegistry} to find a codec to handle the conversion of the provided Java type
571+ * to the underlying CQL type.
478572 *
479573 * @param i the index of the value to set.
480574 * @param v the value to set; may be {@code null}.
481575 * @param targetType The Java type to convert to; must not be {@code null};
482576 * @return this object.
483577 * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object.
578+ * @throws CodecNotFoundException if there is no registered codec to convert the value to the
579+ * underlying CQL type.
484580 */
485581 <V> T set(int i, V v, TypeToken<V> targetType);
486582
487583 /**
488584 * Sets the {@code i}th value to the provided value, converted using the given {@link TypeCodec}.
489585 * <p>
490- * Note that this method allows to entirely bypass the {@link CodecRegistry} currently in use
491- * and forces the driver to use the given codec instead.
586+ * This method entirely bypasses the {@link CodecRegistry} and forces the driver to use the given codec instead.
587+ * This can be useful if the codec would collide with a previously registered one, or if you want to use the
588+ * codec just once without registering it.
492589 * <p>
493590 * It is the caller's responsibility to ensure that the given codec {@link TypeCodec#accepts(DataType) accepts}
494591 * the underlying CQL type; failing to do so may result in {@link InvalidTypeException}s being thrown.
modified driver-core/src/main/java/com/datastax/driver/core/SettableByNameData.java +186 −91
@@ -23,6 +23,7 @@
2323
2424 import com.google.common.reflect.TypeToken;
2525
26+import com.datastax.driver.core.exceptions.CodecNotFoundException;
2627 import com.datastax.driver.core.exceptions.InvalidTypeException;
2728
2829 /**
@@ -33,71 +34,104 @@
3334 /**
3435 * Sets the value for (all occurrences of) variable {@code name} to the
3536 * provided boolean.
37+ * <p>
38+ * This method uses the {@link CodecRegistry} to find a codec to handle the conversion
39+ * to the underlying CQL type (for CQL type {@code boolean}, this will be the built-in codec).
3640 *
3741 * @param name the name of the value to set; if {@code name} is present multiple
3842 * times, all its values are set.
39- * @param v the value to set.
43+ * @param v the value to set. To set the value to NULL, use {@link #setToNull(String)} or
44+ * {@code set(name, v, Boolean.class)}.
4045 * @return this object.
4146 *
4247 * @throws IllegalArgumentException if {@code name} is not a valid name for this object.
48+ * @throws CodecNotFoundException if there is no registered codec to convert the value to the
49+ * underlying CQL type.
4350 */
4451 public T setBool(String name, boolean v);
4552
4653 /**
4754 * Sets the value for (all occurrences of) variable {@code name} to the
4855 * provided byte.
56+ * <p>
57+ * This method uses the {@link CodecRegistry} to find a codec to handle the conversion
58+ * to the underlying CQL type (for CQL type {@code tinyint}, this will be the built-in codec).
4959 *
5060 * @param name the name of the value to set; if {@code name} is present multiple
5161 * times, all its values are set.
52- * @param v the value to set.
62+ * @param v the value to set. To set the value to NULL, use {@link #setToNull(String)} or
63+ * {@code set(name, v, Byte.class)}.
5364 * @return this object.
5465 *
5566 * @throws IllegalArgumentException if {@code name} is not a valid name for this object.
67+ * @throws CodecNotFoundException if there is no registered codec to convert the value to the
68+ * underlying CQL type.
5669 */
5770 public T setByte(String name, byte v);
5871
5972 /**
6073 * Sets the value for (all occurrences of) variable {@code name} to the
6174 * provided short.
75+ * <p>
76+ * This method uses the {@link CodecRegistry} to find a codec to handle the conversion
77+ * to the underlying CQL type (for CQL type {@code smallint}, this will be the built-in codec).
6278 *
6379 * @param name the name of the value to set; if {@code name} is present multiple
6480 * times, all its values are set.
65- * @param v the value to set.
81+ * @param v the value to set. To set the value to NULL, use {@link #setToNull(String)} or
82+ * {@code set(name, v, Short.class)}.
6683 * @return this object.
6784 *
6885 * @throws IllegalArgumentException if {@code name} is not a valid name for this object.
86+ * @throws CodecNotFoundException if there is no registered codec to convert the value to the
87+ * underlying CQL type.
6988 */
7089 public T setShort(String name, short v);
7190
7291 /**
7392 * Sets the value for (all occurrences of) variable {@code name} to the
7493 * provided integer.
94+ * <p>
95+ * This method uses the {@link CodecRegistry} to find a codec to handle the conversion
96+ * to the underlying CQL type (for CQL type {@code int}, this will be the built-in codec).
7597 *
7698 * @param name the name of the value to set; if {@code name} is present multiple
7799 * times, all its values are set.
78- * @param v the value to set.
100+ * @param v the value to set. To set the value to NULL, use {@link #setToNull(String)} or
101+ * {@code set(name, v, Integer.class)}.
79102 * @return this object.
80103 *
81104 * @throws IllegalArgumentException if {@code name} is not a valid name for this object.
105+ * @throws CodecNotFoundException if there is no registered codec to convert the value to the
106+ * underlying CQL type.
82107 */
83108 public T setInt(String name, int v);
84109
85110 /**
86111 * Sets the value for (all occurrences of) variable {@code name} to the
87112 * provided long.
113+ * <p>
114+ * This method uses the {@link CodecRegistry} to find a codec to handle the conversion
115+ * to the underlying CQL type (for CQL type {@code bigint}, this will be the built-in codec).
88116 *
89117 * @param name the name of the value to set; if {@code name} is present multiple
90118 * times, all its values are set.
91- * @param v the value to set.
119+ * @param v the value to set. To set the value to NULL, use {@link #setToNull(String)} or
120+ * {@code set(name, v, Long.class)}.
92121 * @return this object.
93122 *
94123 * @throws IllegalArgumentException if {@code name} is not a valid name for this object.
124+ * @throws CodecNotFoundException if there is no registered codec to convert the value to the
125+ * underlying CQL type.
95126 */
96127 public T setLong(String name, long v);
97128
98129 /**
99130 * Sets the value for (all occurrences of) variable {@code name} to the
100131 * provided date.
132+ * <p>
133+ * This method uses the {@link CodecRegistry} to find a codec to handle the conversion
134+ * to the underlying CQL type (for CQL type {@code timestamp}, this will be the built-in codec).
101135 *
102136 * @param name the name of the value to set; if {@code name} is present multiple
103137 * times, all its values are set.
@@ -105,12 +139,17 @@
105139 * @return this object.
106140 *
107141 * @throws IllegalArgumentException if {@code name} is not a valid name for this object.
142+ * @throws CodecNotFoundException if there is no registered codec to convert the value to the
143+ * underlying CQL type.
108144 */
109145 public T setTimestamp(String name, Date v);
110146
111147 /**
112148 * Sets the value for (all occurrences of) variable {@code name} to the
113149 * provided date (without time).
150+ * <p>
151+ * This method uses the {@link CodecRegistry} to find a codec to handle the conversion
152+ * to the underlying CQL type (for CQL type {@code date}, this will be the built-in codec).
114153 *
115154 * @param name the name of the value to set; if {@code name} is present multiple
116155 * times, all its values are set.
@@ -118,12 +157,17 @@
118157 * @return this object.
119158 *
120159 * @throws IllegalArgumentException if {@code name} is not a valid name for this object.
160+ * @throws CodecNotFoundException if there is no registered codec to convert the value to the
161+ * underlying CQL type.
121162 */
122163 public T setDate(String name, LocalDate v);
123164
124165 /**
125166 * Sets the value for (all occurrences of) variable {@code name} to the
126167 * provided time as a long in nanoseconds since midnight.
168+ * <p>
169+ * This method uses the {@link CodecRegistry} to find a codec to handle the conversion
170+ * to the underlying CQL type (for CQL type {@code time}, this will be the built-in codec).
127171 *
128172 * @param name the name of the value to set; if {@code name} is present multiple
129173 * times, all its values are set.
@@ -131,38 +175,56 @@
131175 * @return this object.
132176 *
133177 * @throws IllegalArgumentException if {@code name} is not a valid name for this object.
178+ * @throws CodecNotFoundException if there is no registered codec to convert the value to the
179+ * underlying CQL type.
134180 */
135181 public T setTime(String name, long v);
136182
137183 /**
138184 * Sets the value for (all occurrences of) variable {@code name} to the
139185 * provided float.
186+ * <p>
187+ * This method uses the {@link CodecRegistry} to find a codec to handle the conversion
188+ * to the underlying CQL type (for CQL type {@code float}, this will be the built-in codec).
140189 *
141190 * @param name the name of the value to set; if {@code name} is present multiple
142191 * times, all its values are set.
143- * @param v the value to set.
192+ * @param v the value to set. To set the value to NULL, use {@link #setToNull(String)} or
193+ * {@code set(name, v, Float.class)}.
144194 * @return this object.
145195 *
146196 * @throws IllegalArgumentException if {@code name} is not a valid name for this object.
197+ * @throws CodecNotFoundException if there is no registered codec to convert the value to the
198+ * underlying CQL type.
147199 */
148200 public T setFloat(String name, float v);
149201
150202 /**
151203 * Sets the value for (all occurrences of) variable {@code name} to the
152204 * provided double.
205+ * <p>
206+ * This method uses the {@link CodecRegistry} to find a codec to handle the conversion
207+ * to the underlying CQL type (for CQL type {@code double}, this will be the built-in codec).
153208 *
154209 * @param name the name of the value to set; if {@code name} is present multiple
155210 * times, all its values are set.
156- * @param v the value to set.
211+ * @param v the value to set. To set the value to NULL, use {@link #setToNull(String)} or
212+ * {@code set(name, v, Double.class)}.
157213 * @return this object.
158214 *
159215 * @throws IllegalArgumentException if {@code name} is not a valid name for this object.
216+ * @throws CodecNotFoundException if there is no registered codec to convert the value to the
217+ * underlying CQL type.
160218 */
161219 public T setDouble(String name, double v);
162220
163221 /**
164222 * Sets the value for (all occurrences of) variable {@code name} to the
165223 * provided string.
224+ * <p>
225+ * This method uses the {@link CodecRegistry} to find a codec to handle the conversion
226+ * to the underlying CQL type (for CQL types {@code text}, {@code varchar} and {@code ascii},
227+ * this will be the built-in codec).
166228 *
167229 * @param name the name of the value to set; if {@code name} is present multiple
168230 * times, all its values are set.
@@ -170,16 +232,17 @@
170232 * @return this object.
171233 *
172234 * @throws IllegalArgumentException if {@code name} is not a valid name for this object.
235+ * @throws CodecNotFoundException if there is no registered codec to convert the value to the
236+ * underlying CQL type.
173237 */
174238 public T setString(String name, String v);
175239
176240 /**
177241 * Sets the value for (all occurrences of) variable {@code name} to the
178242 * provided byte buffer.
179- *
180- * This method validate that the type of the column set is BLOB. If you
181- * want to insert manually serialized data into columns of another type,
182- * use {@link #setBytesUnsafe} instead.
243+ * <p>
244+ * This method uses the {@link CodecRegistry} to find a codec to handle the conversion
245+ * to the underlying CQL type (for CQL type {@code blob}, this will be the built-in codec).
183246 *
184247 * @param name the name of the value to set; if {@code name} is present multiple
185248 * times, all its values are set.
@@ -187,16 +250,17 @@
187250 * @return this object.
188251 *
189252 * @throws IllegalArgumentException if {@code name} is not a valid name for this object.
253+ * @throws CodecNotFoundException if there is no registered codec to convert the value to the
254+ * underlying CQL type.
190255 */
191256 public T setBytes(String name, ByteBuffer v);
192257
193258 /**
194259 * Sets the value for (all occurrences of) variable {@code name} to the
195260 * provided byte buffer.
196- *
197- * Contrary to {@link #setBytes}, this method does not check the
198- * type of the column set. If you insert data that is not compatible with
199- * the type of the column, you will get an {@code InvalidQueryException} at
261+ * <p>
262+ * This method does not use any codec; it sets the value in its binary form directly. If you insert
263+ * data that is not compatible with the underlying CQL type, you will get an {@code InvalidQueryException} at
200264 * execute time.
201265 *
202266 * @param name the name of the value to set; if {@code name} is present multiple
@@ -211,6 +275,9 @@
211275 /**
212276 * Sets the value for (all occurrences of) variable {@code name} to the
213277 * provided big integer.
278+ * <p>
279+ * This method uses the {@link CodecRegistry} to find a codec to handle the conversion
280+ * to the underlying CQL type (for CQL type {@code varint}, this will be the built-in codec).
214281 *
215282 * @param name the name of the value to set; if {@code name} is present multiple
216283 * times, all its values are set.
@@ -218,12 +285,17 @@
218285 * @return this object.
219286 *
220287 * @throws IllegalArgumentException if {@code name} is not a valid name for this object.
288+ * @throws CodecNotFoundException if there is no registered codec to convert the value to the
289+ * underlying CQL type.
221290 */
222291 public T setVarint(String name, BigInteger v);
223292
224293 /**
225294 * Sets the value for (all occurrences of) variable {@code name} to the
226295 * provided big decimal.
296+ * <p>
297+ * This method uses the {@link CodecRegistry} to find a codec to handle the conversion
298+ * to the underlying CQL type (for CQL type {@code decimal}, this will be the built-in codec).
227299 *
228300 * @param name the name of the value to set; if {@code name} is present multiple
229301 * times, all its values are set.
@@ -231,12 +303,18 @@
231303 * @return this object.
232304 *
233305 * @throws IllegalArgumentException if {@code name} is not a valid name for this object.
306+ * @throws CodecNotFoundException if there is no registered codec to convert the value to the
307+ * underlying CQL type.
234308 */
235309 public T setDecimal(String name, BigDecimal v);
236310
237311 /**
238312 * Sets the value for (all occurrences of) variable {@code name} to the
239313 * provided UUID.
314+ * <p>
315+ * This method uses the {@link CodecRegistry} to find a codec to handle the conversion
316+ * to the underlying CQL type (for CQL types {@code uuid} and {@code timeuuid}, this will
317+ * be the built-in codec).
240318 *
241319 * @param name the name of the value to set; if {@code name} is present multiple
242320 * times, all its values are set.
@@ -244,12 +322,17 @@
244322 * @return this object.
245323 *
246324 * @throws IllegalArgumentException if {@code name} is not a valid name for this object.
325+ * @throws CodecNotFoundException if there is no registered codec to convert the value to the
326+ * underlying CQL type.
247327 */
248328 public T setUUID(String name, UUID v);
249329
250330 /**
251331 * Sets the value for (all occurrences of) variable {@code name} to the
252332 * provided inet address.
333+ * <p>
334+ * This method uses the {@link CodecRegistry} to find a codec to handle the conversion
335+ * to the underlying CQL type (for CQL type {@code inet}, this will be the built-in codec).
253336 *
254337 * @param name the name of the value to set; if {@code name} is present multiple
255338 * times, all its values are set.
@@ -257,6 +340,8 @@
257340 * @return this object.
258341 *
259342 * @throws IllegalArgumentException if {@code name} is not a valid name for this object.
343+ * @throws CodecNotFoundException if there is no registered codec to convert the value to the
344+ * underlying CQL type.
260345 */
261346 public T setInet(String name, InetAddress v);
262347
@@ -264,66 +349,64 @@
264349 * Sets the value for (all occurrences of) variable {@code name} to the
265350 * provided list.
266351 * <p>
267- * Please note that {@code null} values inside collections are not supported by CQL.
268- * <p>
269- * Note: if two or more codecs are available
270- * for the underlying CQL type, <em>the one that will be used will be
271- * the first one to be registered.</em>.
272- * <p>
273- * For these reasons, it is generally preferable to use the more
274- * deterministic methods {@link #setList(String, List, Class)} or
275- * {@link #setList(String, List, TypeToken)}.
352+ * This method uses the {@link CodecRegistry} to find a codec to handle the conversion
353+ * to the underlying CQL type (the type of the elements in the Java list is not considered).
354+ * If two or more codecs target that CQL type, the one that was first registered will be used.
355+ * For this reason, it is generally preferable to use the more deterministic methods
356+ * {@link #setList(String, List, Class)} or {@link #setList(String, List, TypeToken)}.
276357 *
277358 * @param name the name of the value to set; if {@code name} is present multiple
278359 * times, all its values are set.
279- * @param v the value to set.
360+ * @param v the value to set. Note that {@code null} values inside collections are not supported by CQL.
280361 * @return this object.
281362 *
282363 * @throws IllegalArgumentException if {@code name} is not a valid name for this object.
283364 * @throws NullPointerException if {@code v} contains null values. Nulls are not supported in collections
284365 * by CQL.
366+ * @throws CodecNotFoundException if there is no registered codec to convert the value to the
367+ * underlying CQL type.
285368 */
286369 public <E> T setList(String name, List<E> v);
287370
288371 /**
289372 * Sets the value for (all occurrences of) variable {@code name} to the provided list,
290- * whose elements are of the provided Java class.
373+ * which elements are of the provided Java class.
291374 * <p>
292- * Please note that {@code null} values inside collections are not supported by CQL.
375+ * This method uses the {@link CodecRegistry} to find a codec to handle the conversion of lists of the given
376+ * Java type to the underlying CQL type.
293377 * <p>
294- * Note about performance: this method is able to cache codecs used to serialize the list elements,
295- * and thus should be used instead of {@link #setList(String, List)}
296- * whenever possible, because it performs significantly better.
378+ * If the type of the elements is generic, use {@link #setList(String, List, TypeToken)}.
297379 *
298380 * @param name the name of the value to set; if {@code name} is present multiple
299- * @param v the value to set.
381+ * @param v the value to set. Note that {@code null} values inside collections are not supported by CQL.
300382 * @param elementsClass the class for the elements of the list.
301383 * @return this object.
302384 *
303385 * @throws IllegalArgumentException if {@code name} is not a valid name for this object.
304386 * @throws NullPointerException if {@code v} contains null values. Nulls are not supported in collections
305387 * by CQL.
388+ * @throws CodecNotFoundException if there is no registered codec to convert the value to the
389+ * underlying CQL type.
306390 */
307391 public <E> T setList(String name, List<E> v, Class<E> elementsClass);
308392
309393 /**
310394 * Sets the value for (all occurrences of) variable {@code name} to the provided list,
311- * whose elements are of the provided Java type.
395+ * which elements are of the provided Java type.
312396 * <p>
313- * Please note that {@code null} values inside collections are not supported by CQL.
314- * <p>
315- * Note about performance: this method is able to cache codecs used to serialize the list elements,
316- * and thus should be used instead of {@link #setList(String, List)}
317- * whenever possible, because it performs significantly better.
397+ * This method uses the {@link CodecRegistry} to find a codec to handle the conversion of lists of the given
398+ * Java type to the underlying CQL type.
318399 *
319400 * @param name the name of the value to set; if {@code name} is present multiple
320- * @param v the value to set.
401+ * @param v the value to set. Note that {@code null} values inside collections are not supported by CQL.
321402 * @param elementsType the type for the elements of the list.
322403 * @return this object.
323404 *
324405 * @throws IllegalArgumentException if {@code name} is not a valid name for this object.
325406 * @throws NullPointerException if {@code v} contains null values. Nulls are not supported in collections
326407 * by CQL.
408+ * @throws CodecNotFoundException if there is no registered codec to convert the value to the
409+ * underlying CQL type.
327410 */
328411 public <E> T setList(String name, List<E> v, TypeToken<E> elementsType);
329412
@@ -331,41 +414,37 @@
331414 * Sets the value for (all occurrences of) variable {@code name} to the
332415 * provided map.
333416 * <p>
334- * Please note that {@code null} values are not supported inside collection by CQL.
335- * <p>
336- * <p>
337- * Note: if two or more codecs are available
338- * for the underlying CQL type, <em>the one that will be used will be
339- * the first one to be registered.</em>.
340- * <p>
341- * For these reasons, it is generally preferable to use the more
342- * deterministic methods {@link #setMap(String, Map, Class, Class)} or
343- * {@link #setMap(String, Map, TypeToken, TypeToken)}.
417+ * This method uses the {@link CodecRegistry} to find a codec to handle the conversion
418+ * to the underlying CQL type (the type of the elements in the Java map is not considered).
419+ * If two or more codecs target that CQL type, the one that was first registered will be used.
420+ * For this reason, it is generally preferable to use the more deterministic methods
421+ * {@link #setMap(String, Map, Class, Class)} or {@link #setMap(String, Map, TypeToken, TypeToken)}.
344422 *
345423 * @param name the name of the value to set; if {@code name} is present multiple
346424 * times, all its values are set.
347- * @param v the value to set.
425+ * @param v the value to set. Note that {@code null} values inside collections are not supported by CQL.
348426 * @return this object.
349427 *
350428 * @throws IllegalArgumentException if {@code name} is not a valid name for this object.
351429 * @throws NullPointerException if {@code v} contains null values. Nulls are not supported in collections
352430 * by CQL.
431+ * @throws CodecNotFoundException if there is no registered codec to convert the value to the
432+ * underlying CQL type.
353433 */
354434 public <K, V> T setMap(String name, Map<K, V> v);
355435
356436 /**
357437 * Sets the value for (all occurrences of) variable {@code name} to the provided map,
358- * whose keys and values are of the provided Java classes.
438+ * which keys and values are of the provided Java classes.
359439 * <p>
360- * Please note that {@code null} values inside collections are not supported by CQL.
440+ * This method uses the {@link CodecRegistry} to find a codec to handle the conversion of lists of the given
441+ * Java types to the underlying CQL type.
361442 * <p>
362- * Note about performance: this method is able to cache codecs used to serialize the map entries,
363- * and thus should be used instead of {@link #setMap(String, Map)}
364- * whenever possible, because it performs significantly better.
443+ * If the type of the keys or values is generic, use {@link #setMap(String, Map, TypeToken, TypeToken)}.
365444 *
366445 * @param name the name of the value to set; if {@code name} is present multiple
367446 * times, all its values are set.
368- * @param v the value to set.
447+ * @param v the value to set. Note that {@code null} values inside collections are not supported by CQL.
369448 * @param keysClass the class for the keys of the map.
370449 * @param valuesClass the class for the values of the map.
371450 * @return this object.
@@ -373,22 +452,21 @@
373452 * @throws IllegalArgumentException if {@code name} is not a valid name for this object.
374453 * @throws NullPointerException if {@code v} contains null values. Nulls are not supported in collections
375454 * by CQL.
455+ * @throws CodecNotFoundException if there is no registered codec to convert the value to the
456+ * underlying CQL type.
376457 */
377458 public <K, V> T setMap(String name, Map<K, V> v, Class<K> keysClass, Class<V> valuesClass);
378459
379460 /**
380461 * Sets the value for (all occurrences of) variable {@code name} to the provided map,
381- * whose keys and values are of the provided Java types.
462+ * which keys and values are of the provided Java types.
382463 * <p>
383- * Please note that {@code null} values inside collections are not supported by CQL.
384- * <p>
385- * Note about performance: this method is able to cache codecs used to serialize the map entries,
386- * and thus should be used instead of {@link #setMap(String, Map)}
387- * whenever possible, because it performs significantly better.
464+ * This method uses the {@link CodecRegistry} to find a codec to handle the conversion of lists of the given
465+ * Java types to the underlying CQL type.
388466 *
389467 * @param name the name of the value to set; if {@code name} is present multiple
390468 * times, all its values are set.
391- * @param v the value to set.
469+ * @param v the value to set. Note that {@code null} values inside collections are not supported by CQL.
392470 * @param keysType the type for the keys of the map.
393471 * @param valuesType the type for the values of the map.
394472 * @return this object.
@@ -396,6 +474,8 @@
396474 * @throws IllegalArgumentException if {@code name} is not a valid name for this object.
397475 * @throws NullPointerException if {@code v} contains null values. Nulls are not supported in collections
398476 * by CQL.
477+ * @throws CodecNotFoundException if there is no registered codec to convert the value to the
478+ * underlying CQL type.
399479 */
400480 public <K, V> T setMap(String name, Map<K, V> v, TypeToken<K> keysType, TypeToken<V> valuesType);
401481
@@ -403,72 +483,73 @@
403483 * Sets the value for (all occurrences of) variable {@code name} to the
404484 * provided set.
405485 * <p>
406- * Please note that {@code null} values are not supported inside collection by CQL.
407- * <p>
408- * Note: if two or more codecs are available
409- * for the underlying CQL type, <em>the one that will be used will be
410- * the first one to be registered.</em>.
411- * <p>
412- * For these reasons, it is generally preferable to use the more
413- * deterministic methods {@link #setSet(String, Set, Class)} or
414- * {@link #setSet(String, Set, TypeToken)}.
486+ * This method uses the {@link CodecRegistry} to find a codec to handle the conversion
487+ * to the underlying CQL type (the type of the elements in the Java set is not considered).
488+ * If two or more codecs target that CQL type, the one that was first registered will be used.
489+ * For this reason, it is generally preferable to use the more deterministic methods
490+ * {@link #setSet(String, Set, Class)} or {@link #setSet(String, Set, TypeToken)}.
415491 *
416492 * @param name the name of the value to set; if {@code name} is present multiple
417493 * times, all its values are set.
418- * @param v the value to set.
494+ * @param v the value to set. Note that {@code null} values inside collections are not supported by CQL.
419495 * @return this object.
420496 *
421497 * @throws IllegalArgumentException if {@code name} is not a valid name for this object.
422498 * @throws NullPointerException if {@code v} contains null values. Nulls are not supported in collections
423499 * by CQL.
500+ * @throws CodecNotFoundException if there is no registered codec to convert the value to the
501+ * underlying CQL type.
424502 */
425503 public <E> T setSet(String name, Set<E> v);
426504
427505 /**
428506 * Sets the value for (all occurrences of) variable {@code name} to the provided set,
429- * whose elements are of the provided Java class.
507+ * which elements are of the provided Java class.
430508 * <p>
431- * Please note that {@code null} values inside collections are not supported by CQL.
509+ * This method uses the {@link CodecRegistry} to find a codec to handle the conversion of sets of the given
510+ * Java type to the underlying CQL type.
432511 * <p>
433- * Note about performance: this method is able to cache codecs used to serialize the set elements,
434- * and thus should be used instead of {@link #setSet(String, Set)}
435- * whenever possible, because it performs significantly better.
512+ * If the type of the elements is generic, use {@link #setSet(String, Set, TypeToken)}.
436513 *
437514 * @param name the name of the value to set; if {@code name} is present multiple
438- * @param v the value to set.
515+ * @param v the value to set. Note that {@code null} values inside collections are not supported by CQL.
439516 * @param elementsClass the class for the elements of the set.
440517 * @return this object.
441518 *
442519 * @throws IllegalArgumentException if {@code name} is not a valid name for this object.
443520 * @throws NullPointerException if {@code v} contains null values. Nulls are not supported in collections
444521 * by CQL.
522+ * @throws CodecNotFoundException if there is no registered codec to convert the value to the
523+ * underlying CQL type.
445524 */
446525 public <E> T setSet(String name, Set<E> v, Class<E> elementsClass);
447526
448527 /**
449528 * Sets the value for (all occurrences of) variable {@code name} to the provided set,
450- * whose elements are of the provided Java type.
529+ * which elements are of the provided Java type.
451530 * <p>
452- * Please note that {@code null} values inside collections are not supported by CQL.
453- * <p>
454- * Note about performance: this method is able to cache codecs used to serialize the set elements,
455- * and thus should be used instead of {@link #setSet(String, Set)}
456- * whenever possible, because it performs significantly better.
531+ * This method uses the {@link CodecRegistry} to find a codec to handle the conversion of sets of the given
532+ * Java type to the underlying CQL type.
457533 *
458534 * @param name the name of the value to set; if {@code name} is present multiple
459- * @param v the value to set.
535+ * @param v the value to set. Note that {@code null} values inside collections are not supported by CQL.
460536 * @param elementsType the type for the elements of the set.
461537 * @return this object.
462538 *
463539 * @throws IllegalArgumentException if {@code name} is not a valid name for this object.
464540 * @throws NullPointerException if {@code v} contains null values. Nulls are not supported in collections
465541 * by CQL.
542+ * @throws CodecNotFoundException if there is no registered codec to convert the value to the
543+ * underlying CQL type.
466544 */
467545 public <E> T setSet(String name, Set<E> v, TypeToken<E> elementsType);
468546
469547 /**
470548 * Sets the value for (all occurrences of) variable {@code name} to the
471549 * provided UDT value.
550+ * <p>
551+ * This method uses the {@link CodecRegistry} to find a codec to handle the conversion of {@code UDTValue}
552+ * to the underlying CQL type.
472553 *
473554 * @param name the name of the value to set; if {@code name} is present multiple
474555 * times, all its values are set.
@@ -476,12 +557,17 @@
476557 * @return this object.
477558 *
478559 * @throws IllegalArgumentException if {@code name} is not a valid name for this object.
560+ * @throws CodecNotFoundException if there is no registered codec to convert the value to the
561+ * underlying CQL type.
479562 */
480563 public T setUDTValue(String name, UDTValue v);
481564
482565 /**
483566 * Sets the value for (all occurrences of) variable {@code name} to the
484567 * provided tuple value.
568+ * <p>
569+ * This method uses the {@link CodecRegistry} to find a codec to handle the conversion of {@code TupleValue}
570+ * to the underlying CQL type.
485571 *
486572 * @param name the name of the value to set; if {@code name} is present multiple
487573 * times, all its values are set.
@@ -489,6 +575,8 @@
489575 * @return this object.
490576 *
491577 * @throws IllegalArgumentException if {@code name} is not a valid name for this object.
578+ * @throws CodecNotFoundException if there is no registered codec to convert the value to the
579+ * underlying CQL type.
492580 */
493581 public T setTupleValue(String name, TupleValue v);
494582
@@ -507,8 +595,10 @@
507595 /**
508596 * Sets the value for (all occurrences of) variable {@code name} to the provided value of the provided Java class.
509597 * <p>
510- * A suitable {@link TypeCodec} instance for the underlying CQL type and the provided class must
511- * have been previously registered with the {@link CodecRegistry} currently in use.
598+ * This method uses the {@link CodecRegistry} to find a codec to handle the conversion of the provided Java class
599+ * to the underlying CQL type.
600+ * <p>
601+ * If the Java type is generic, use {@link #set(String, Object, TypeToken)} instead.
512602 *
513603 * @param name the name of the value to set; if {@code name} is present multiple
514604 * times, all its values are set.
@@ -516,14 +606,16 @@
516606 * @param targetClass The Java class to convert to; must not be {@code null};
517607 * @return this object.
518608 * @throws IllegalArgumentException if {@code name} is not a valid name for this object.
609+ * @throws CodecNotFoundException if there is no registered codec to convert the value to the
610+ * underlying CQL type.
519611 */
520612 <V> T set(String name, V v, Class<V> targetClass);
521613
522614 /**
523615 * Sets the value for (all occurrences of) variable {@code name} to the provided value of the provided Java type.
524616 * <p>
525- * A suitable {@link TypeCodec} instance for the underlying CQL type and the provided class must
526- * have been previously registered with the {@link CodecRegistry} currently in use.
617+ * This method uses the {@link CodecRegistry} to find a codec to handle the conversion of the provided Java type
618+ * to the underlying CQL type.
527619 *
528620 * @param name the name of the value to set; if {@code name} is present multiple
529621 * times, all its values are set.
@@ -531,6 +623,8 @@
531623 * @param targetType The Java type to convert to; must not be {@code null};
532624 * @return this object.
533625 * @throws IllegalArgumentException if {@code name} is not a valid name for this object.
626+ * @throws CodecNotFoundException if there is no registered codec to convert the value to the
627+ * underlying CQL type.
534628 */
535629 <V> T set(String name, V v, TypeToken<V> targetType);
536630
@@ -538,8 +632,9 @@
538632 * Sets the value for (all occurrences of) variable {@code name} to the provided value,
539633 * converted using the given {@link TypeCodec}.
540634 * <p>
541- * Note that this method allows to entirely bypass the {@link CodecRegistry} currently in use
542- * and forces the driver to use the given codec instead.
635+ * This method entirely bypasses the {@link CodecRegistry} and forces the driver to use the given codec instead.
636+ * This can be useful if the codec would collide with a previously registered one, or if you want to use the
637+ * codec just once without registering it.
543638 * <p>
544639 * It is the caller's responsibility to ensure that the given codec {@link TypeCodec#accepts(DataType) accepts}
545640 * the underlying CQL type; failing to do so may result in {@link InvalidTypeException}s being thrown.