/** * Returns the {@code i}th value as the Java type matching its CQL type. * * <p>This method calls {@link #getObject(int, CodecRegistry)} with {@link * CodecRegistry#DEFAULT_INSTANCE}. It's safe to use if you don't use any custom codecs, or if * your custom codecs are in the default registry; otherwise, use the other method and provide the * registry that contains your codecs. * * @param i the index to retrieve. * @return the value of the {@code i}th value of this statement. * @throws IllegalStateException if this statement does not have values. * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object. */ public Object getObject(int i) { return getObject(i, CodecRegistry.DEFAULT_INSTANCE); }
@Test(groups = "unit") public void should_serialize_collections_of_serializable_elements() { Set<UUID> set = Sets.newHashSet(UUID.randomUUID()); List<Date> list = Lists.newArrayList(new Date()); Map<BigInteger, String> map = ImmutableMap.of(new BigInteger("1"), "foo"); BuiltStatement query = insertInto("foo").value("v", set); assertThat(query.getQueryString()).isEqualTo("INSERT INTO foo (v) VALUES (?);"); assertThat(query.getObject(0)).isEqualTo(set); query = insertInto("foo").value("v", list); assertThat(query.getQueryString()).isEqualTo("INSERT INTO foo (v) VALUES (?);"); assertThat(query.getObject(0)).isEqualTo(list); query = insertInto("foo").value("v", map); assertThat(query.getQueryString()).isEqualTo("INSERT INTO foo (v) VALUES (?);"); assertThat(query.getObject(0)).isEqualTo(map); }
/** * Returns the {@code i}th value as the Java type matching its CQL type. * <p/> * This method calls {@link #getObject(int, CodecRegistry)} with * {@link CodecRegistry#DEFAULT_INSTANCE}. * It's safe to use if you don't use any custom codecs, or if your custom codecs are in * the default registry; otherwise, use the other method and provide the registry that * contains your codecs. * * @param i the index to retrieve. * @return the value of the {@code i}th value of this statement. * @throws IllegalStateException if this statement does not have values. * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object. */ public Object getObject(int i) { return getObject(i, CodecRegistry.DEFAULT_INSTANCE); }
/** * Returns the {@code i}th value as the Java type matching its CQL type. * <p/> * This method calls {@link #getObject(int, CodecRegistry)} with * {@link CodecRegistry#DEFAULT_INSTANCE}. * It's safe to use if you don't use any custom codecs, or if your custom codecs are in * the default registry; otherwise, use the other method and provide the registry that * contains your codecs. * * @param i the index to retrieve. * @return the value of the {@code i}th value of this statement. * @throws IllegalStateException if this statement does not have values. * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object. */ public Object getObject(int i) { return getObject(i, CodecRegistry.DEFAULT_INSTANCE); }
/** * Returns the {@code i}th value as the Java type matching its CQL type. * <p/> * This method calls {@link #getObject(int, CodecRegistry)} with * {@link CodecRegistry#DEFAULT_INSTANCE}. * It's safe to use if you don't use any custom codecs, or if your custom codecs are in * the default registry; otherwise, use the other method and provide the registry that * contains your codecs. * * @param i the index to retrieve. * @return the value of the {@code i}th value of this statement. * @throws IllegalStateException if this statement does not have values. * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object. */ public Object getObject(int i) { return getObject(i, CodecRegistry.DEFAULT_INSTANCE); }
@Test(groups = "unit") public void should_serialize_collections_of_serializable_elements() { Set<UUID> set = Sets.newHashSet(UUID.randomUUID()); List<Date> list = Lists.newArrayList(new Date()); Map<BigInteger, String> map = ImmutableMap.of(new BigInteger("1"), "foo"); BuiltStatement query = insertInto("foo").value("v", set); assertThat(query.getQueryString()).isEqualTo("INSERT INTO foo (v) VALUES (?);"); assertThat(query.getObject(0)).isEqualTo(set); query = insertInto("foo").value("v", list); assertThat(query.getQueryString()).isEqualTo("INSERT INTO foo (v) VALUES (?);"); assertThat(query.getObject(0)).isEqualTo(list); query = insertInto("foo").value("v", map); assertThat(query.getQueryString()).isEqualTo("INSERT INTO foo (v) VALUES (?);"); assertThat(query.getObject(0)).isEqualTo(map); }