/src/java/org/apache/cassandra/cql3/functions/types/SettableByIndexData.java

https://github.com/beobal/cassandra · Java · 583 lines · 44 code · 36 blank · 503 comment · 0 complexity · d9b27108d66d39b87fb79e0ac0128e60 MD5 · raw file

  1. /*
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. package org.apache.cassandra.cql3.functions.types;
  19. import java.math.BigDecimal;
  20. import java.math.BigInteger;
  21. import java.net.InetAddress;
  22. import java.nio.ByteBuffer;
  23. import java.util.*;
  24. import com.google.common.reflect.TypeToken;
  25. import org.apache.cassandra.cql3.functions.types.exceptions.CodecNotFoundException;
  26. import org.apache.cassandra.cql3.functions.types.exceptions.InvalidTypeException;
  27. /**
  28. * Collection of (typed) CQL values that can be set by index (starting at zero).
  29. */
  30. public interface SettableByIndexData<T extends SettableByIndexData<T>>
  31. {
  32. /**
  33. * Sets the {@code i}th value to the provided boolean.
  34. *
  35. * <p>This method uses the {@link CodecRegistry} to find a codec to handle the conversion to the
  36. * underlying CQL type (for CQL type {@code boolean}, this will be the built-in codec).
  37. *
  38. * @param i the index of the value to set.
  39. * @param v the value to set. To set the value to NULL, use {@link #setToNull(int)} or {@code
  40. * set(i, v, Boolean.class)}
  41. * @return this object.
  42. * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object.
  43. * @throws CodecNotFoundException if there is no registered codec to convert the value to the
  44. * underlying CQL type.
  45. */
  46. public T setBool(int i, boolean v);
  47. /**
  48. * Set the {@code i}th value to the provided byte.
  49. *
  50. * <p>This method uses the {@link CodecRegistry} to find a codec to handle the conversion to the
  51. * underlying CQL type (for CQL type {@code tinyint}, this will be the built-in codec).
  52. *
  53. * @param i the index of the value to set.
  54. * @param v the value to set. To set the value to NULL, use {@link #setToNull(int)} or {@code
  55. * set(i, v, Byte.class)}
  56. * @return this object.
  57. * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object.
  58. * @throws CodecNotFoundException if there is no registered codec to convert the value to the
  59. * underlying CQL type.
  60. */
  61. public T setByte(int i, byte v);
  62. /**
  63. * Set the {@code i}th value to the provided short.
  64. *
  65. * <p>This method uses the {@link CodecRegistry} to find a codec to handle the conversion to the
  66. * underlying CQL type (for CQL type {@code smallint}, this will be the built-in codec).
  67. *
  68. * @param i the index of the value to set.
  69. * @param v the value to set. To set the value to NULL, use {@link #setToNull(int)} or {@code
  70. * set(i, v, Short.class)}
  71. * @return this object.
  72. * @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 value to the
  74. * underlying CQL type.
  75. */
  76. public T setShort(int i, short v);
  77. /**
  78. * Set the {@code i}th value to the provided integer.
  79. *
  80. * <p>This method uses the {@link CodecRegistry} to find a codec to handle the conversion to the
  81. * underlying CQL type (for CQL type {@code int}, this will be the built-in codec).
  82. *
  83. * @param i the index of the value to set.
  84. * @param v the value to set. To set the value to NULL, use {@link #setToNull(int)} or {@code
  85. * set(i, v, Integer.class)}
  86. * @return this object.
  87. * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object.
  88. * @throws CodecNotFoundException if there is no registered codec to convert the value to the
  89. * underlying CQL type.
  90. */
  91. public T setInt(int i, int v);
  92. /**
  93. * Sets the {@code i}th value to the provided long.
  94. *
  95. * <p>This method uses the {@link CodecRegistry} to find a codec to handle the conversion to the
  96. * underlying CQL type (for CQL type {@code bigint}, this will be the built-in codec).
  97. *
  98. * @param i the index of the value to set.
  99. * @param v the value to set. To set the value to NULL, use {@link #setToNull(int)} or {@code
  100. * set(i, v, Long.class)}
  101. * @return this object.
  102. * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object.
  103. * @throws CodecNotFoundException if there is no registered codec to convert the value to the
  104. * underlying CQL type.
  105. */
  106. public T setLong(int i, long v);
  107. /**
  108. * Set the {@code i}th value to the provided date.
  109. *
  110. * <p>This method uses the {@link CodecRegistry} to find a codec to handle the conversion to the
  111. * underlying CQL type (for CQL type {@code timestamp}, this will be the built-in codec).
  112. *
  113. * @param i the index of the value to set.
  114. * @param v the value to set.
  115. * @return this object.
  116. * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object.
  117. * @throws CodecNotFoundException if there is no registered codec to convert the value to the
  118. * underlying CQL type.
  119. */
  120. public T setTimestamp(int i, Date v);
  121. /**
  122. * Set the {@code i}th value to the provided date (without time).
  123. *
  124. * <p>This method uses the {@link CodecRegistry} to find a codec to handle the conversion to the
  125. * underlying CQL type (for CQL type {@code date}, this will be the built-in codec).
  126. *
  127. * @param i the index of the value to set.
  128. * @param v the value to set.
  129. * @return this object.
  130. * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object.
  131. * @throws CodecNotFoundException if there is no registered codec to convert the value to the
  132. * underlying CQL type.
  133. */
  134. public T setDate(int i, LocalDate v);
  135. /**
  136. * Set the {@code i}th value to the provided time as a long in nanoseconds since midnight.
  137. *
  138. * <p>This method uses the {@link CodecRegistry} to find a codec to handle the conversion to the
  139. * underlying CQL type (for CQL type {@code time}, this will be the built-in codec).
  140. *
  141. * @param i the index of the value to set.
  142. * @param v the value to set.
  143. * @return this object.
  144. * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object.
  145. * @throws CodecNotFoundException if there is no registered codec to convert the value to the
  146. * underlying CQL type.
  147. */
  148. public T setTime(int i, long v);
  149. /**
  150. * Sets the {@code i}th value to the provided float.
  151. *
  152. * <p>This method uses the {@link CodecRegistry} to find a codec to handle the conversion to the
  153. * underlying CQL type (for CQL type {@code float}, this will be the built-in codec).
  154. *
  155. * @param i the index of the value to set.
  156. * @param v the value to set. To set the value to NULL, use {@link #setToNull(int)} or {@code
  157. * set(i, v, Float.class)}
  158. * @return this object.
  159. * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object.
  160. * @throws CodecNotFoundException if there is no registered codec to convert the value to the
  161. * underlying CQL type.
  162. */
  163. public T setFloat(int i, float v);
  164. /**
  165. * Sets the {@code i}th value to the provided double.
  166. *
  167. * <p>This method uses the {@link CodecRegistry} to find a codec to handle the conversion to the
  168. * underlying CQL type (for CQL type {@code double}, this will be the built-in codec).
  169. *
  170. * @param i the index of the value to set.
  171. * @param v the value to set. To set the value to NULL, use {@link #setToNull(int)} or {@code
  172. * set(i, v, Double.class)}.
  173. * @return this object.
  174. * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object.
  175. * @throws CodecNotFoundException if there is no registered codec to convert the value to the
  176. * underlying CQL type.
  177. */
  178. public T setDouble(int i, double v);
  179. /**
  180. * Sets the {@code i}th value to the provided string.
  181. *
  182. * <p>This method uses the {@link CodecRegistry} to find a codec to handle the conversion to the
  183. * underlying CQL type (for CQL types {@code text}, {@code varchar} and {@code ascii}, this will
  184. * be the built-in codec).
  185. *
  186. * @param i the index of the value to set.
  187. * @param v the value to set.
  188. * @return this object.
  189. * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object.
  190. * @throws CodecNotFoundException if there is no registered codec to convert the value to the
  191. * underlying CQL type.
  192. */
  193. public T setString(int i, String v);
  194. /**
  195. * Sets the {@code i}th value to the provided byte buffer.
  196. *
  197. * <p>This method uses the {@link CodecRegistry} to find a codec to handle the conversion to the
  198. * underlying CQL type (for CQL type {@code blob}, this will be the built-in codec).
  199. *
  200. * @param i the index of the value to set.
  201. * @param v the value to set.
  202. * @return this object.
  203. * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object.
  204. * @throws CodecNotFoundException if there is no registered codec to convert the value to the
  205. * underlying CQL type.
  206. */
  207. public T setBytes(int i, ByteBuffer v);
  208. /**
  209. * Sets the {@code i}th value to the provided byte buffer.
  210. *
  211. * <p>This method does not use any codec; it sets the value in its binary form directly. If you
  212. * insert data that is not compatible with the underlying CQL type, you will get an {@code
  213. * InvalidQueryException} at execute time.
  214. *
  215. * @param i the index of the value to set.
  216. * @param v the value to set.
  217. * @return this object.
  218. * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object.
  219. */
  220. public T setBytesUnsafe(int i, ByteBuffer v);
  221. /**
  222. * Sets the {@code i}th value to the provided big integer.
  223. *
  224. * <p>This method uses the {@link CodecRegistry} to find a codec to handle the conversion to the
  225. * underlying CQL type (for CQL type {@code varint}, this will be the built-in codec).
  226. *
  227. * @param i the index of the value to set.
  228. * @param v the value to set.
  229. * @return this object.
  230. * @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 value to the
  232. * underlying CQL type.
  233. */
  234. public T setVarint(int i, BigInteger v);
  235. /**
  236. * Sets the {@code i}th value to the provided big decimal.
  237. *
  238. * <p>This method uses the {@link CodecRegistry} to find a codec to handle the conversion to the
  239. * underlying CQL type (for CQL type {@code decimal}, this will be the built-in codec).
  240. *
  241. * @param i the index of the value to set.
  242. * @param v the value to set.
  243. * @return this object.
  244. * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object.
  245. * @throws CodecNotFoundException if there is no registered codec to convert the value to the
  246. * underlying CQL type.
  247. */
  248. public T setDecimal(int i, BigDecimal v);
  249. /**
  250. * Sets the {@code i}th value to the provided UUID.
  251. *
  252. * <p>This method uses the {@link CodecRegistry} to find a codec to handle the conversion to the
  253. * underlying CQL type (for CQL types {@code uuid} and {@code timeuuid}, this will be the built-in
  254. * codec).
  255. *
  256. * @param i the index of the value to set.
  257. * @param v the value to set.
  258. * @return this object.
  259. * @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.
  262. */
  263. public T setUUID(int i, UUID v);
  264. /**
  265. * Sets the {@code i}th value to the provided inet address.
  266. *
  267. * <p>This method uses the {@link CodecRegistry} to find a codec to handle the conversion to the
  268. * underlying CQL type (for CQL type {@code inet}, this will be the built-in codec).
  269. *
  270. * @param i the index of the value to set.
  271. * @param v the value to set.
  272. * @return this object.
  273. * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object.
  274. * @throws CodecNotFoundException if there is no registered codec to convert the value to the
  275. * underlying CQL type.
  276. */
  277. public T setInet(int i, InetAddress v);
  278. /**
  279. * Sets the {@code i}th value to the provided list.
  280. *
  281. * <p>This method uses the {@link CodecRegistry} to find a codec to handle the conversion to the
  282. * underlying CQL type (the type of the elements in the Java list is not considered). If two or
  283. * more codecs target that CQL type, the one that was first registered will be used. For this
  284. * reason, it is generally preferable to use the more deterministic methods {@link #setList(int,
  285. * List, Class)} or {@link #setList(int, List, TypeToken)}.
  286. *
  287. * @param i the index of the value to set.
  288. * @param v the value to set. Note that {@code null} values inside collections are not supported
  289. * by CQL.
  290. * @return this object.
  291. * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object.
  292. * @throws NullPointerException if {@code v} contains null values. Nulls are not supported in
  293. * collections by CQL.
  294. * @throws CodecNotFoundException if there is no registered codec to convert the value to the
  295. * underlying CQL type.
  296. */
  297. public <E> T setList(int i, List<E> v);
  298. /**
  299. * Sets the {@code i}th value to the provided list, which elements are of the provided Java class.
  300. *
  301. * <p>This method uses the {@link CodecRegistry} to find a codec to handle the conversion of lists
  302. * of the given Java type to the underlying CQL type.
  303. *
  304. * <p>If the type of the elements is generic, use {@link #setList(int, List, TypeToken)}.
  305. *
  306. * @param i the index of the value to set.
  307. * @param v the value to set. Note that {@code null} values inside collections are not supported
  308. * by CQL.
  309. * @param elementsClass the class for the elements of the list.
  310. * @return this object.
  311. * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object.
  312. * @throws NullPointerException if {@code v} contains null values. Nulls are not supported in
  313. * collections by CQL.
  314. * @throws CodecNotFoundException if there is no registered codec to convert the value to the
  315. * underlying CQL type.
  316. */
  317. public <E> T setList(int i, List<E> v, Class<E> elementsClass);
  318. /**
  319. * Sets the {@code i}th value to the provided list, which elements are of the provided Java type.
  320. *
  321. * <p>This method uses the {@link CodecRegistry} to find a codec to handle the conversion of lists
  322. * of the given Java type to the underlying CQL type.
  323. *
  324. * @param i the index of the value to set.
  325. * @param v the value to set. Note that {@code null} values inside collections are not supported
  326. * by CQL.
  327. * @param elementsType the type for the elements of the list.
  328. * @return this object.
  329. * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object.
  330. * @throws NullPointerException if {@code v} contains null values. Nulls are not supported in
  331. * collections by CQL.
  332. * @throws CodecNotFoundException if there is no registered codec to convert the value to the
  333. * underlying CQL type.
  334. */
  335. public <E> T setList(int i, List<E> v, TypeToken<E> elementsType);
  336. /**
  337. * Sets the {@code i}th value to the provided map.
  338. *
  339. * <p>This method uses the {@link CodecRegistry} to find a codec to handle the conversion to the
  340. * underlying CQL type (the type of the elements in the Java map is not considered). If two or
  341. * more codecs target that CQL type, the one that was first registered will be used. For this
  342. * reason, it is generally preferable to use the more deterministic methods {@link #setMap(int,
  343. * Map, Class, Class)} or {@link #setMap(int, Map, TypeToken, TypeToken)}.
  344. *
  345. * @param i the index of the value to set.
  346. * @param v the value to set. Note that {@code null} values inside collections are not supported
  347. * by CQL.
  348. * @return this object.
  349. * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object.
  350. * @throws NullPointerException if {@code v} contains null values. Nulls are not supported in
  351. * collections by CQL.
  352. * @throws CodecNotFoundException if there is no registered codec to convert the value to the
  353. * underlying CQL type.
  354. */
  355. public <K, V> T setMap(int i, Map<K, V> v);
  356. /**
  357. * Sets the {@code i}th value to the provided map, which keys and values are of the provided Java
  358. * classes.
  359. *
  360. * <p>This method uses the {@link CodecRegistry} to find a codec to handle the conversion of lists
  361. * of the given Java types to the underlying CQL type.
  362. *
  363. * <p>If the type of the keys or values is generic, use {@link #setMap(int, Map, TypeToken,
  364. * TypeToken)}.
  365. *
  366. * @param i the index of the value to set.
  367. * @param v the value to set. Note that {@code null} values inside collections are not supported
  368. * by CQL.
  369. * @param keysClass the class for the keys of the map.
  370. * @param valuesClass the class for the values of the map.
  371. * @return this object.
  372. * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object.
  373. * @throws NullPointerException if {@code v} contains null values. Nulls are not supported in
  374. * collections by CQL.
  375. * @throws CodecNotFoundException if there is no registered codec to convert the value to the
  376. * underlying CQL type.
  377. */
  378. public <K, V> T setMap(int i, Map<K, V> v, Class<K> keysClass, Class<V> valuesClass);
  379. /**
  380. * Sets the {@code i}th value to the provided map, which keys and values are of the provided Java
  381. * types.
  382. *
  383. * <p>This method uses the {@link CodecRegistry} to find a codec to handle the conversion of lists
  384. * of the given Java types to the underlying CQL type.
  385. *
  386. * @param i the index of the value to set.
  387. * @param v the value to set. Note that {@code null} values inside collections are not supported
  388. * by CQL.
  389. * @param keysType the type for the keys of the map.
  390. * @param valuesType the type for the values of the map.
  391. * @return this object.
  392. * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object.
  393. * @throws NullPointerException if {@code v} contains null values. Nulls are not supported in
  394. * collections by CQL.
  395. * @throws CodecNotFoundException if there is no registered codec to convert the value to the
  396. * underlying CQL type.
  397. */
  398. public <K, V> T setMap(int i, Map<K, V> v, TypeToken<K> keysType, TypeToken<V> valuesType);
  399. /**
  400. * Sets the {@code i}th value to the provided set.
  401. *
  402. * <p>This method uses the {@link CodecRegistry} to find a codec to handle the conversion to the
  403. * underlying CQL type (the type of the elements in the Java set is not considered). If two or
  404. * more codecs target that CQL type, the one that was first registered will be used. For this
  405. * reason, it is generally preferable to use the more deterministic methods {@link #setSet(int,
  406. * Set, Class)} or {@link #setSet(int, Set, TypeToken)}.
  407. *
  408. * @param i the index of the value to set.
  409. * @param v the value to set. Note that {@code null} values inside collections are not supported
  410. * by CQL.
  411. * @return this object.
  412. * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object.
  413. * @throws NullPointerException if {@code v} contains null values. Nulls are not supported in
  414. * collections by CQL.
  415. * @throws CodecNotFoundException if there is no registered codec to convert the value to the
  416. * underlying CQL type.
  417. */
  418. public <E> T setSet(int i, Set<E> v);
  419. /**
  420. * Sets the {@code i}th value to the provided set, which elements are of the provided Java class.
  421. *
  422. * <p>This method uses the {@link CodecRegistry} to find a codec to handle the conversion of sets
  423. * of the given Java type to the underlying CQL type.
  424. *
  425. * <p>If the type of the elements is generic, use {@link #setSet(int, Set, TypeToken)}.
  426. *
  427. * @param i the index of the value to set.
  428. * @param v the value to set. Note that {@code null} values inside collections are not supported
  429. * by CQL.
  430. * @param elementsClass the class for the elements of the set.
  431. * @return this object.
  432. * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object.
  433. * @throws NullPointerException if {@code v} contains null values. Nulls are not supported in
  434. * collections by CQL.
  435. * @throws CodecNotFoundException if there is no registered codec to convert the value to the
  436. * underlying CQL type.
  437. */
  438. public <E> T setSet(int i, Set<E> v, Class<E> elementsClass);
  439. /**
  440. * Sets the {@code i}th value to the provided set, which elements are of the provided Java type.
  441. *
  442. * <p>This method uses the {@link CodecRegistry} to find a codec to handle the conversion of sets
  443. * of the given Java type to the underlying CQL type.
  444. *
  445. * @param i the index of the value to set.
  446. * @param v the value to set. Note that {@code null} values inside collections are not supported
  447. * by CQL.
  448. * @param elementsType the type for the elements of the set.
  449. * @return this object.
  450. * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object.
  451. * @throws NullPointerException if {@code v} contains null values. Nulls are not supported in
  452. * collections by CQL.
  453. * @throws CodecNotFoundException if there is no registered codec to convert the value to the
  454. * underlying CQL type.
  455. */
  456. public <E> T setSet(int i, Set<E> v, TypeToken<E> elementsType);
  457. /**
  458. * Sets the {@code i}th value to the provided UDT value.
  459. *
  460. * <p>This method uses the {@link CodecRegistry} to find a codec to handle the conversion of
  461. * {@code UDTValue} to the underlying CQL type.
  462. *
  463. * @param i the index of the value to set.
  464. * @param v the value to set.
  465. * @return this object.
  466. * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object.
  467. * @throws CodecNotFoundException if there is no registered codec to convert the value to the
  468. * underlying CQL type.
  469. */
  470. public T setUDTValue(int i, UDTValue v);
  471. /**
  472. * Sets the {@code i}th value to the provided tuple value.
  473. *
  474. * <p>This method uses the {@link CodecRegistry} to find a codec to handle the conversion of
  475. * {@code TupleValue} to the underlying CQL type.
  476. *
  477. * @param i the index of the value to set.
  478. * @param v the value to set.
  479. * @return this object.
  480. * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object.
  481. * @throws CodecNotFoundException if there is no registered codec to convert the value to the
  482. * underlying CQL type.
  483. */
  484. public T setTupleValue(int i, TupleValue v);
  485. /**
  486. * Sets the {@code i}th value to {@code null}.
  487. *
  488. * <p>This is mainly intended for CQL types which map to native Java types.
  489. *
  490. * @param i the index of the value to set.
  491. * @return this object.
  492. * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object.
  493. */
  494. public T setToNull(int i);
  495. /**
  496. * Sets the {@code i}th value to the provided value of the provided Java class.
  497. *
  498. * <p>This method uses the {@link CodecRegistry} to find a codec to handle the conversion of the
  499. * provided Java class to the underlying CQL type.
  500. *
  501. * <p>If the Java type is generic, use {@link #set(int, Object, TypeToken)} instead.
  502. *
  503. * @param i the index of the value to set.
  504. * @param v the value to set; may be {@code null}.
  505. * @param targetClass The Java class to convert to; must not be {@code null};
  506. * @return this object.
  507. * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object.
  508. * @throws CodecNotFoundException if there is no registered codec to convert the value to the
  509. * underlying CQL type.
  510. */
  511. <V> T set(int i, V v, Class<V> targetClass);
  512. /**
  513. * Sets the {@code i}th value to the provided value of the provided Java type.
  514. *
  515. * <p>This method uses the {@link CodecRegistry} to find a codec to handle the conversion of the
  516. * provided Java type to the underlying CQL type.
  517. *
  518. * @param i the index of the value to set.
  519. * @param v the value to set; may be {@code null}.
  520. * @param targetType The Java type to convert to; must not be {@code null};
  521. * @return this object.
  522. * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object.
  523. * @throws CodecNotFoundException if there is no registered codec to convert the value to the
  524. * underlying CQL type.
  525. */
  526. <V> T set(int i, V v, TypeToken<V> targetType);
  527. /**
  528. * Sets the {@code i}th value to the provided value, converted using the given {@link TypeCodec}.
  529. *
  530. * <p>This method entirely bypasses the {@link CodecRegistry} and forces the driver to use the
  531. * given codec instead. This can be useful if the codec would collide with a previously registered
  532. * one, or if you want to use the codec just once without registering it.
  533. *
  534. * <p>It is the caller's responsibility to ensure that the given codec {@link
  535. * TypeCodec#accepts(DataType) accepts} the underlying CQL type; failing to do so may result in
  536. * {@link InvalidTypeException}s being thrown.
  537. *
  538. * @param i the index of the value to set.
  539. * @param v the value to set; may be {@code null}.
  540. * @param codec The {@link TypeCodec} to use to serialize the value; may not be {@code null}.
  541. * @return this object.
  542. * @throws InvalidTypeException if the given codec does not {@link TypeCodec#accepts(DataType)
  543. * accept} the underlying CQL type.
  544. * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object.
  545. */
  546. <V> T set(int i, V v, TypeCodec<V> codec);
  547. }