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

https://github.com/beobal/cassandra · Java · 620 lines · 44 code · 36 blank · 540 comment · 0 complexity · d37e235b29eebb76ebc7701fa7cf9a4d 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 set by name.
  29. */
  30. public interface SettableByNameData<T extends SettableData<T>>
  31. {
  32. /**
  33. * Sets the value for (all occurrences of) variable {@code name} 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 name the name of the value to set; if {@code name} is present multiple times, all its
  39. * values are set.
  40. * @param v the value to set. To set the value to NULL, use {@link #setToNull(String)} or {@code
  41. * set(name, v, Boolean.class)}.
  42. * @return this object.
  43. * @throws IllegalArgumentException if {@code name} is not a valid name for this object.
  44. * @throws CodecNotFoundException if there is no registered codec to convert the value to the
  45. * underlying CQL type.
  46. */
  47. public T setBool(String name, boolean v);
  48. /**
  49. * Sets the value for (all occurrences of) variable {@code name} to the provided byte.
  50. *
  51. * <p>This method uses the {@link CodecRegistry} to find a codec to handle the conversion to the
  52. * underlying CQL type (for CQL type {@code tinyint}, this will be the built-in codec).
  53. *
  54. * @param name the name of the value to set; if {@code name} is present multiple times, all its
  55. * values are set.
  56. * @param v the value to set. To set the value to NULL, use {@link #setToNull(String)} or {@code
  57. * set(name, v, Byte.class)}.
  58. * @return this object.
  59. * @throws IllegalArgumentException if {@code name} is not a valid name for this object.
  60. * @throws CodecNotFoundException if there is no registered codec to convert the value to the
  61. * underlying CQL type.
  62. */
  63. public T setByte(String name, byte v);
  64. /**
  65. * Sets the value for (all occurrences of) variable {@code name} to the provided short.
  66. *
  67. * <p>This method uses the {@link CodecRegistry} to find a codec to handle the conversion to the
  68. * underlying CQL type (for CQL type {@code smallint}, this will be the built-in codec).
  69. *
  70. * @param name the name of the value to set; if {@code name} is present multiple times, all its
  71. * values are set.
  72. * @param v the value to set. To set the value to NULL, use {@link #setToNull(String)} or {@code
  73. * set(name, v, Short.class)}.
  74. * @return this object.
  75. * @throws IllegalArgumentException if {@code name} is not a valid name for this object.
  76. * @throws CodecNotFoundException if there is no registered codec to convert the value to the
  77. * underlying CQL type.
  78. */
  79. public T setShort(String name, short v);
  80. /**
  81. * Sets the value for (all occurrences of) variable {@code name} to the provided integer.
  82. *
  83. * <p>This method uses the {@link CodecRegistry} to find a codec to handle the conversion to the
  84. * underlying CQL type (for CQL type {@code int}, this will be the built-in codec).
  85. *
  86. * @param name the name of the value to set; if {@code name} is present multiple times, all its
  87. * values are set.
  88. * @param v the value to set. To set the value to NULL, use {@link #setToNull(String)} or {@code
  89. * set(name, v, Integer.class)}.
  90. * @return this object.
  91. * @throws IllegalArgumentException if {@code name} is not a valid name for this object.
  92. * @throws CodecNotFoundException if there is no registered codec to convert the value to the
  93. * underlying CQL type.
  94. */
  95. public T setInt(String name, int v);
  96. /**
  97. * Sets the value for (all occurrences of) variable {@code name} to the provided long.
  98. *
  99. * <p>This method uses the {@link CodecRegistry} to find a codec to handle the conversion to the
  100. * underlying CQL type (for CQL type {@code bigint}, this will be the built-in codec).
  101. *
  102. * @param name the name of the value to set; if {@code name} is present multiple times, all its
  103. * values are set.
  104. * @param v the value to set. To set the value to NULL, use {@link #setToNull(String)} or {@code
  105. * set(name, v, Long.class)}.
  106. * @return this object.
  107. * @throws IllegalArgumentException if {@code name} is not a valid name for this object.
  108. * @throws CodecNotFoundException if there is no registered codec to convert the value to the
  109. * underlying CQL type.
  110. */
  111. public T setLong(String name, long v);
  112. /**
  113. * Sets the value for (all occurrences of) variable {@code name} to the provided date.
  114. *
  115. * <p>This method uses the {@link CodecRegistry} to find a codec to handle the conversion to the
  116. * underlying CQL type (for CQL type {@code timestamp}, this will be the built-in codec).
  117. *
  118. * @param name the name of the value to set; if {@code name} is present multiple times, all its
  119. * values are set.
  120. * @param v the value to set.
  121. * @return this object.
  122. * @throws IllegalArgumentException if {@code name} is not a valid name for this object.
  123. * @throws CodecNotFoundException if there is no registered codec to convert the value to the
  124. * underlying CQL type.
  125. */
  126. public T setTimestamp(String name, Date v);
  127. /**
  128. * Sets the value for (all occurrences of) variable {@code name} to the provided date (without
  129. * time).
  130. *
  131. * <p>This method uses the {@link CodecRegistry} to find a codec to handle the conversion to the
  132. * underlying CQL type (for CQL type {@code date}, this will be the built-in codec).
  133. *
  134. * @param name the name of the value to set; if {@code name} is present multiple times, all its
  135. * values are set.
  136. * @param v the value to set.
  137. * @return this object.
  138. * @throws IllegalArgumentException if {@code name} is not a valid name for this object.
  139. * @throws CodecNotFoundException if there is no registered codec to convert the value to the
  140. * underlying CQL type.
  141. */
  142. public T setDate(String name, LocalDate v);
  143. /**
  144. * Sets the value for (all occurrences of) variable {@code name} to the provided time as a long in
  145. * nanoseconds since midnight.
  146. *
  147. * <p>This method uses the {@link CodecRegistry} to find a codec to handle the conversion to the
  148. * underlying CQL type (for CQL type {@code time}, this will be the built-in codec).
  149. *
  150. * @param name the name of the value to set; if {@code name} is present multiple times, all its
  151. * values are set.
  152. * @param v the value to set.
  153. * @return this object.
  154. * @throws IllegalArgumentException if {@code name} is not a valid name for this object.
  155. * @throws CodecNotFoundException if there is no registered codec to convert the value to the
  156. * underlying CQL type.
  157. */
  158. public T setTime(String name, long v);
  159. /**
  160. * Sets the value for (all occurrences of) variable {@code name} to the provided float.
  161. *
  162. * <p>This method uses the {@link CodecRegistry} to find a codec to handle the conversion to the
  163. * underlying CQL type (for CQL type {@code float}, this will be the built-in codec).
  164. *
  165. * @param name the name of the value to set; if {@code name} is present multiple times, all its
  166. * values are set.
  167. * @param v the value to set. To set the value to NULL, use {@link #setToNull(String)} or {@code
  168. * set(name, v, Float.class)}.
  169. * @return this object.
  170. * @throws IllegalArgumentException if {@code name} is not a valid name for this object.
  171. * @throws CodecNotFoundException if there is no registered codec to convert the value to the
  172. * underlying CQL type.
  173. */
  174. public T setFloat(String name, float v);
  175. /**
  176. * Sets the value for (all occurrences of) variable {@code name} to the provided double.
  177. *
  178. * <p>This method uses the {@link CodecRegistry} to find a codec to handle the conversion to the
  179. * underlying CQL type (for CQL type {@code double}, this will be the built-in codec).
  180. *
  181. * @param name the name of the value to set; if {@code name} is present multiple times, all its
  182. * values are set.
  183. * @param v the value to set. To set the value to NULL, use {@link #setToNull(String)} or {@code
  184. * set(name, v, Double.class)}.
  185. * @return this object.
  186. * @throws IllegalArgumentException if {@code name} is not a valid name for this object.
  187. * @throws CodecNotFoundException if there is no registered codec to convert the value to the
  188. * underlying CQL type.
  189. */
  190. public T setDouble(String name, double v);
  191. /**
  192. * Sets the value for (all occurrences of) variable {@code name} to the provided string.
  193. *
  194. * <p>This method uses the {@link CodecRegistry} to find a codec to handle the conversion to the
  195. * underlying CQL type (for CQL types {@code text}, {@code varchar} and {@code ascii}, this will
  196. * be the built-in codec).
  197. *
  198. * @param name the name of the value to set; if {@code name} is present multiple times, all its
  199. * values are set.
  200. * @param v the value to set.
  201. * @return this object.
  202. * @throws IllegalArgumentException if {@code name} is not a valid name for this object.
  203. * @throws CodecNotFoundException if there is no registered codec to convert the value to the
  204. * underlying CQL type.
  205. */
  206. public T setString(String name, String v);
  207. /**
  208. * Sets the value for (all occurrences of) variable {@code name} to the provided byte buffer.
  209. *
  210. * <p>This method uses the {@link CodecRegistry} to find a codec to handle the conversion to the
  211. * underlying CQL type (for CQL type {@code blob}, this will be the built-in codec).
  212. *
  213. * @param name the name of the value to set; if {@code name} is present multiple times, all its
  214. * values are set.
  215. * @param v the value to set.
  216. * @return this object.
  217. * @throws IllegalArgumentException if {@code name} is not a valid name for this object.
  218. * @throws CodecNotFoundException if there is no registered codec to convert the value to the
  219. * underlying CQL type.
  220. */
  221. public T setBytes(String name, ByteBuffer v);
  222. /**
  223. * Sets the value for (all occurrences of) variable {@code name} to the provided byte buffer.
  224. *
  225. * <p>This method does not use any codec; it sets the value in its binary form directly. If you
  226. * insert data that is not compatible with the underlying CQL type, you will get an {@code
  227. * InvalidQueryException} at execute time.
  228. *
  229. * @param name the name of the value to set; if {@code name} is present multiple times, all its
  230. * values are set.
  231. * @param v the value to set.
  232. * @return this object.
  233. * @throws IllegalArgumentException if {@code name} is not a valid name for this object.
  234. */
  235. public T setBytesUnsafe(String name, ByteBuffer v);
  236. /**
  237. * Sets the value for (all occurrences of) variable {@code name} to the provided big integer.
  238. *
  239. * <p>This method uses the {@link CodecRegistry} to find a codec to handle the conversion to the
  240. * underlying CQL type (for CQL type {@code varint}, this will be the built-in codec).
  241. *
  242. * @param name the name of the value to set; if {@code name} is present multiple times, all its
  243. * values are set.
  244. * @param v the value to set.
  245. * @return this object.
  246. * @throws IllegalArgumentException if {@code name} is not a valid name for this object.
  247. * @throws CodecNotFoundException if there is no registered codec to convert the value to the
  248. * underlying CQL type.
  249. */
  250. public T setVarint(String name, BigInteger v);
  251. /**
  252. * Sets the value for (all occurrences of) variable {@code name} to the provided big decimal.
  253. *
  254. * <p>This method uses the {@link CodecRegistry} to find a codec to handle the conversion to the
  255. * underlying CQL type (for CQL type {@code decimal}, this will be the built-in codec).
  256. *
  257. * @param name the name of the value to set; if {@code name} is present multiple times, all its
  258. * values are set.
  259. * @param v the value to set.
  260. * @return this object.
  261. * @throws IllegalArgumentException if {@code name} is not a valid name for this object.
  262. * @throws CodecNotFoundException if there is no registered codec to convert the value to the
  263. * underlying CQL type.
  264. */
  265. public T setDecimal(String name, BigDecimal v);
  266. /**
  267. * Sets the value for (all occurrences of) variable {@code name} to the provided UUID.
  268. *
  269. * <p>This method uses the {@link CodecRegistry} to find a codec to handle the conversion to the
  270. * underlying CQL type (for CQL types {@code uuid} and {@code timeuuid}, this will be the built-in
  271. * codec).
  272. *
  273. * @param name the name of the value to set; if {@code name} is present multiple times, all its
  274. * values are set.
  275. * @param v the value to set.
  276. * @return this object.
  277. * @throws IllegalArgumentException if {@code name} is not a valid name for this object.
  278. * @throws CodecNotFoundException if there is no registered codec to convert the value to the
  279. * underlying CQL type.
  280. */
  281. public T setUUID(String name, UUID v);
  282. /**
  283. * Sets the value for (all occurrences of) variable {@code name} to the provided inet address.
  284. *
  285. * <p>This method uses the {@link CodecRegistry} to find a codec to handle the conversion to the
  286. * underlying CQL type (for CQL type {@code inet}, this will be the built-in codec).
  287. *
  288. * @param name the name of the value to set; if {@code name} is present multiple times, all its
  289. * values are set.
  290. * @param v the value to set.
  291. * @return this object.
  292. * @throws IllegalArgumentException if {@code name} is not a valid name for this object.
  293. * @throws CodecNotFoundException if there is no registered codec to convert the value to the
  294. * underlying CQL type.
  295. */
  296. public T setInet(String name, InetAddress v);
  297. /**
  298. * Sets the value for (all occurrences of) variable {@code name} to the provided list.
  299. *
  300. * <p>This method uses the {@link CodecRegistry} to find a codec to handle the conversion to the
  301. * underlying CQL type (the type of the elements in the Java list is not considered). If two or
  302. * more codecs target that CQL type, the one that was first registered will be used. For this
  303. * reason, it is generally preferable to use the more deterministic methods {@link
  304. * #setList(String, List, Class)} or {@link #setList(String, List, TypeToken)}.
  305. *
  306. * @param name the name of the value to set; if {@code name} is present multiple times, all its
  307. * values are set.
  308. * @param v the value to set. Note that {@code null} values inside collections are not supported
  309. * by CQL.
  310. * @return this object.
  311. * @throws IllegalArgumentException if {@code name} is not a valid name 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(String name, List<E> v);
  318. /**
  319. * Sets the value for (all occurrences of) variable {@code name} to the provided list, which
  320. * elements are of the provided Java class.
  321. *
  322. * <p>This method uses the {@link CodecRegistry} to find a codec to handle the conversion of lists
  323. * of the given Java type to the underlying CQL type.
  324. *
  325. * <p>If the type of the elements is generic, use {@link #setList(String, List, TypeToken)}.
  326. *
  327. * @param name the name of the value to set; if {@code name} is present multiple
  328. * @param v the value to set. Note that {@code null} values inside collections are not supported
  329. * by CQL.
  330. * @param elementsClass the class for the elements of the list.
  331. * @return this object.
  332. * @throws IllegalArgumentException if {@code name} is not a valid name for this object.
  333. * @throws NullPointerException if {@code v} contains null values. Nulls are not supported in
  334. * collections by CQL.
  335. * @throws CodecNotFoundException if there is no registered codec to convert the value to the
  336. * underlying CQL type.
  337. */
  338. public <E> T setList(String name, List<E> v, Class<E> elementsClass);
  339. /**
  340. * Sets the value for (all occurrences of) variable {@code name} to the provided list, which
  341. * elements are of the provided Java type.
  342. *
  343. * <p>This method uses the {@link CodecRegistry} to find a codec to handle the conversion of lists
  344. * of the given Java type to the underlying CQL type.
  345. *
  346. * @param name the name of the value to set; if {@code name} is present multiple
  347. * @param v the value to set. Note that {@code null} values inside collections are not supported
  348. * by CQL.
  349. * @param elementsType the type for the elements of the list.
  350. * @return this object.
  351. * @throws IllegalArgumentException if {@code name} is not a valid name for this object.
  352. * @throws NullPointerException if {@code v} contains null values. Nulls are not supported in
  353. * collections by CQL.
  354. * @throws CodecNotFoundException if there is no registered codec to convert the value to the
  355. * underlying CQL type.
  356. */
  357. public <E> T setList(String name, List<E> v, TypeToken<E> elementsType);
  358. /**
  359. * Sets the value for (all occurrences of) variable {@code name} to the provided map.
  360. *
  361. * <p>This method uses the {@link CodecRegistry} to find a codec to handle the conversion to the
  362. * underlying CQL type (the type of the elements in the Java map is not considered). If two or
  363. * more codecs target that CQL type, the one that was first registered will be used. For this
  364. * reason, it is generally preferable to use the more deterministic methods {@link #setMap(String,
  365. * Map, Class, Class)} or {@link #setMap(String, Map, TypeToken, TypeToken)}.
  366. *
  367. * @param name the name of the value to set; if {@code name} is present multiple times, all its
  368. * values are set.
  369. * @param v the value to set. Note that {@code null} values inside collections are not supported
  370. * by CQL.
  371. * @return this object.
  372. * @throws IllegalArgumentException if {@code name} is not a valid name 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(String name, Map<K, V> v);
  379. /**
  380. * Sets the value for (all occurrences of) variable {@code name} to the provided map, which keys
  381. * and values are of the provided Java classes.
  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. * <p>If the type of the keys or values is generic, use {@link #setMap(String, Map, TypeToken,
  387. * TypeToken)}.
  388. *
  389. * @param name the name of the value to set; if {@code name} is present multiple times, all its
  390. * values are set.
  391. * @param v the value to set. Note that {@code null} values inside collections are not supported
  392. * by CQL.
  393. * @param keysClass the class for the keys of the map.
  394. * @param valuesClass the class for the values of the map.
  395. * @return this object.
  396. * @throws IllegalArgumentException if {@code name} is not a valid name for this object.
  397. * @throws NullPointerException if {@code v} contains null values. Nulls are not supported in
  398. * collections by CQL.
  399. * @throws CodecNotFoundException if there is no registered codec to convert the value to the
  400. * underlying CQL type.
  401. */
  402. public <K, V> T setMap(String name, Map<K, V> v, Class<K> keysClass, Class<V> valuesClass);
  403. /**
  404. * Sets the value for (all occurrences of) variable {@code name} to the provided map, which keys
  405. * and values are of the provided Java types.
  406. *
  407. * <p>This method uses the {@link CodecRegistry} to find a codec to handle the conversion of lists
  408. * of the given Java types to the underlying CQL type.
  409. *
  410. * @param name the name of the value to set; if {@code name} is present multiple times, all its
  411. * values are set.
  412. * @param v the value to set. Note that {@code null} values inside collections are not supported
  413. * by CQL.
  414. * @param keysType the type for the keys of the map.
  415. * @param valuesType the type for the values of the map.
  416. * @return this object.
  417. * @throws IllegalArgumentException if {@code name} is not a valid name for this object.
  418. * @throws NullPointerException if {@code v} contains null values. Nulls are not supported in
  419. * collections by CQL.
  420. * @throws CodecNotFoundException if there is no registered codec to convert the value to the
  421. * underlying CQL type.
  422. */
  423. public <K, V> T setMap(String name, Map<K, V> v, TypeToken<K> keysType, TypeToken<V> valuesType);
  424. /**
  425. * Sets the value for (all occurrences of) variable {@code name} to the provided set.
  426. *
  427. * <p>This method uses the {@link CodecRegistry} to find a codec to handle the conversion to the
  428. * underlying CQL type (the type of the elements in the Java set is not considered). If two or
  429. * more codecs target that CQL type, the one that was first registered will be used. For this
  430. * reason, it is generally preferable to use the more deterministic methods {@link #setSet(String,
  431. * Set, Class)} or {@link #setSet(String, Set, TypeToken)}.
  432. *
  433. * @param name the name of the value to set; if {@code name} is present multiple times, all its
  434. * values are set.
  435. * @param v the value to set. Note that {@code null} values inside collections are not supported
  436. * by CQL.
  437. * @return this object.
  438. * @throws IllegalArgumentException if {@code name} is not a valid name for this object.
  439. * @throws NullPointerException if {@code v} contains null values. Nulls are not supported in
  440. * collections by CQL.
  441. * @throws CodecNotFoundException if there is no registered codec to convert the value to the
  442. * underlying CQL type.
  443. */
  444. public <E> T setSet(String name, Set<E> v);
  445. /**
  446. * Sets the value for (all occurrences of) variable {@code name} to the provided set, which
  447. * elements are of the provided Java class.
  448. *
  449. * <p>This method uses the {@link CodecRegistry} to find a codec to handle the conversion of sets
  450. * of the given Java type to the underlying CQL type.
  451. *
  452. * <p>If the type of the elements is generic, use {@link #setSet(String, Set, TypeToken)}.
  453. *
  454. * @param name the name of the value to set; if {@code name} is present multiple
  455. * @param v the value to set. Note that {@code null} values inside collections are not supported
  456. * by CQL.
  457. * @param elementsClass the class for the elements of the set.
  458. * @return this object.
  459. * @throws IllegalArgumentException if {@code name} is not a valid name for this object.
  460. * @throws NullPointerException if {@code v} contains null values. Nulls are not supported in
  461. * collections by CQL.
  462. * @throws CodecNotFoundException if there is no registered codec to convert the value to the
  463. * underlying CQL type.
  464. */
  465. public <E> T setSet(String name, Set<E> v, Class<E> elementsClass);
  466. /**
  467. * Sets the value for (all occurrences of) variable {@code name} to the provided set, which
  468. * elements are of the provided Java type.
  469. *
  470. * <p>This method uses the {@link CodecRegistry} to find a codec to handle the conversion of sets
  471. * of the given Java type to the underlying CQL type.
  472. *
  473. * @param name the name of the value to set; if {@code name} is present multiple
  474. * @param v the value to set. Note that {@code null} values inside collections are not supported
  475. * by CQL.
  476. * @param elementsType the type for the elements of the set.
  477. * @return this object.
  478. * @throws IllegalArgumentException if {@code name} is not a valid name for this object.
  479. * @throws NullPointerException if {@code v} contains null values. Nulls are not supported in
  480. * collections by CQL.
  481. * @throws CodecNotFoundException if there is no registered codec to convert the value to the
  482. * underlying CQL type.
  483. */
  484. public <E> T setSet(String name, Set<E> v, TypeToken<E> elementsType);
  485. /**
  486. * Sets the value for (all occurrences of) variable {@code name} to the provided UDT value.
  487. *
  488. * <p>This method uses the {@link CodecRegistry} to find a codec to handle the conversion of
  489. * {@code UDTValue} to the underlying CQL type.
  490. *
  491. * @param name the name of the value to set; if {@code name} is present multiple times, all its
  492. * values are set.
  493. * @param v the value to set.
  494. * @return this object.
  495. * @throws IllegalArgumentException if {@code name} is not a valid name for this object.
  496. * @throws CodecNotFoundException if there is no registered codec to convert the value to the
  497. * underlying CQL type.
  498. */
  499. public T setUDTValue(String name, UDTValue v);
  500. /**
  501. * Sets the value for (all occurrences of) variable {@code name} to the provided tuple value.
  502. *
  503. * <p>This method uses the {@link CodecRegistry} to find a codec to handle the conversion of
  504. * {@code TupleValue} to the underlying CQL type.
  505. *
  506. * @param name the name of the value to set; if {@code name} is present multiple times, all its
  507. * values are set.
  508. * @param v the value to set.
  509. * @return this object.
  510. * @throws IllegalArgumentException if {@code name} is not a valid name for this object.
  511. * @throws CodecNotFoundException if there is no registered codec to convert the value to the
  512. * underlying CQL type.
  513. */
  514. public T setTupleValue(String name, TupleValue v);
  515. /**
  516. * Sets the value for (all occurrences of) variable {@code name} to {@code null}.
  517. *
  518. * <p>This is mainly intended for CQL types which map to native Java types.
  519. *
  520. * @param name the name of the value to set; if {@code name} is present multiple times, all its
  521. * values are set.
  522. * @return this object.
  523. * @throws IllegalArgumentException if {@code name} is not a valid name for this object.
  524. */
  525. public T setToNull(String name);
  526. /**
  527. * Sets the value for (all occurrences of) variable {@code name} to the provided value of the
  528. * provided Java class.
  529. *
  530. * <p>This method uses the {@link CodecRegistry} to find a codec to handle the conversion of the
  531. * provided Java class to the underlying CQL type.
  532. *
  533. * <p>If the Java type is generic, use {@link #set(String, Object, TypeToken)} instead.
  534. *
  535. * @param name the name of the value to set; if {@code name} is present multiple times, all its
  536. * values are set.
  537. * @param v the value to set; may be {@code null}.
  538. * @param targetClass The Java class to convert to; must not be {@code null};
  539. * @return this object.
  540. * @throws IllegalArgumentException if {@code name} is not a valid name for this object.
  541. * @throws CodecNotFoundException if there is no registered codec to convert the value to the
  542. * underlying CQL type.
  543. */
  544. <V> T set(String name, V v, Class<V> targetClass);
  545. /**
  546. * Sets the value for (all occurrences of) variable {@code name} to the provided value of the
  547. * provided Java type.
  548. *
  549. * <p>This method uses the {@link CodecRegistry} to find a codec to handle the conversion of the
  550. * provided Java type to the underlying CQL type.
  551. *
  552. * @param name the name of the value to set; if {@code name} is present multiple times, all its
  553. * values are set.
  554. * @param v the value to set; may be {@code null}.
  555. * @param targetType The Java type to convert to; must not be {@code null};
  556. * @return this object.
  557. * @throws IllegalArgumentException if {@code name} is not a valid name for this object.
  558. * @throws CodecNotFoundException if there is no registered codec to convert the value to the
  559. * underlying CQL type.
  560. */
  561. <V> T set(String name, V v, TypeToken<V> targetType);
  562. /**
  563. * Sets the value for (all occurrences of) variable {@code name} to the provided value, converted
  564. * using the given {@link TypeCodec}.
  565. *
  566. * <p>This method entirely bypasses the {@link CodecRegistry} and forces the driver to use the
  567. * given codec instead. This can be useful if the codec would collide with a previously registered
  568. * one, or if you want to use the codec just once without registering it.
  569. *
  570. * <p>It is the caller's responsibility to ensure that the given codec {@link
  571. * TypeCodec#accepts(DataType) accepts} the underlying CQL type; failing to do so may result in
  572. * {@link InvalidTypeException}s being thrown.
  573. *
  574. * @param name the name of the value to set; if {@code name} is present multiple times, all its
  575. * values are set.
  576. * @param v the value to set; may be {@code null}.
  577. * @param codec The {@link TypeCodec} to use to serialize the value; may not be {@code null}.
  578. * @return this object.
  579. * @throws InvalidTypeException if the given codec does not {@link TypeCodec#accepts(DataType)
  580. * accept} the underlying CQL type.
  581. * @throws IllegalArgumentException if {@code name} is not a valid name for this object.
  582. */
  583. <V> T set(String name, V v, TypeCodec<V> codec);
  584. }