Elffuss BraidHub

kikocis/java-driver public

Preserve non-standard formatting for TypeTokens.
Changeset66b1492994327e28d0ab66a4fe6f4916dd54cde245407ec877636e3003371eec
Authorolim7t <omichallat+github@gmail.com> · 2015-12-09 19:46 +01:00
Committerolim7t <omichallat+github@gmail.com> · 2015-12-09 20:10 +01:00
Parentsd457d3dbaa2b

Browse the files at this changeset

10 files changed

modified driver-core/src/main/java/com/datastax/driver/core/TypeTokens.java +22 −24
@@ -39,9 +39,9 @@
3939 * are of the given type.
4040 */
4141 public static <T> TypeToken<List<T>> listOf(Class<T> eltType) {
42- return new TypeToken<List<T>>() {
43- }.where(new TypeParameter<T>() {
44- }, eltType);
42+ // @formatter:off
43+ return new TypeToken<List<T>>(){}.where(new TypeParameter<T>(){}, eltType);
44+ // @formatter:on
4545 }
4646
4747 /**
@@ -54,9 +54,9 @@
5454 * are of the given type.
5555 */
5656 public static <T> TypeToken<List<T>> listOf(TypeToken<T> eltType) {
57- return new TypeToken<List<T>>() {
58- }.where(new TypeParameter<T>() {
59- }, eltType);
57+ // @formatter:off
58+ return new TypeToken<List<T>>(){}.where(new TypeParameter<T>(){}, eltType);
59+ // @formatter:on
6060 }
6161
6262 /**
@@ -69,9 +69,9 @@
6969 * are of the given type.
7070 */
7171 public static <T> TypeToken<Set<T>> setOf(Class<T> eltType) {
72- return new TypeToken<Set<T>>() {
73- }.where(new TypeParameter<T>() {
74- }, eltType);
72+ // @formatter:off
73+ return new TypeToken<Set<T>>(){}.where(new TypeParameter<T>(){}, eltType);
74+ // @formatter:on
7575 }
7676
7777 /**
@@ -84,9 +84,9 @@
8484 * are of the given type.
8585 */
8686 public static <T> TypeToken<Set<T>> setOf(TypeToken<T> eltType) {
87- return new TypeToken<Set<T>>() {
88- }.where(new TypeParameter<T>() {
89- }, eltType);
87+ // @formatter:off
88+ return new TypeToken<Set<T>>(){}.where(new TypeParameter<T>(){}, eltType);
89+ // @formatter:on
9090 }
9191
9292 /**
@@ -101,12 +101,11 @@
101101 * and values are of the given key and value types
102102 */
103103 public static <K, V> TypeToken<Map<K, V>> mapOf(Class<K> keyType, Class<V> valueType) {
104- return new TypeToken<Map<K, V>>() {
105- }
106- .where(new TypeParameter<K>() {
107- }, keyType)
108- .where(new TypeParameter<V>() {
109- }, valueType);
104+ // @formatter:off
105+ return new TypeToken<Map<K, V>>(){}
106+ .where(new TypeParameter<K>(){}, keyType)
107+ .where(new TypeParameter<V>(){}, valueType);
108+ // @formatter:on
110109 }
111110
112111 /**
@@ -121,11 +120,10 @@
121120 * and values are of the given key and value types
122121 */
123122 public static <K, V> TypeToken<Map<K, V>> mapOf(TypeToken<K> keyType, TypeToken<V> valueType) {
124- return new TypeToken<Map<K, V>>() {
125- }
126- .where(new TypeParameter<K>() {
127- }, keyType)
128- .where(new TypeParameter<V>() {
129- }, valueType);
123+ // @formatter:off
124+ return new TypeToken<Map<K, V>>(){}
125+ .where(new TypeParameter<K>(){}, keyType)
126+ .where(new TypeParameter<V>(){}, valueType);
127+ // @formatter:on
130128 }
131129 }
modified driver-core/src/test/java/com/datastax/driver/core/CodecRegistryTest.java +1 −2
@@ -27,8 +27,7 @@
2727 import static org.mockito.Mockito.when;
2828
2929 public class CodecRegistryTest {
30- TypeToken<List<Integer>> LIST_OF_INT_TOKEN = new TypeToken<List<Integer>>() {
31- };
30+ TypeToken<List<Integer>> LIST_OF_INT_TOKEN = TypeTokens.listOf(Integer.class);
3231
3332 @Test(groups = "unit")
3433 public void should_ignore_codec_colliding_with_already_registered_codec() {
modified driver-core/src/test/java/com/datastax/driver/core/TypeCodecEncapsulationIntegrationTest.java +36 −49
@@ -35,6 +35,15 @@
3535
3636 public class TypeCodecEncapsulationIntegrationTest extends CCMBridge.PerClassSingleNodeCluster {
3737
38+ // @formatter:off
39+ private static final TypeToken<NumberBox<Integer>> NUMBERBOX_OF_INTEGER_TOKEN = new TypeToken<NumberBox<Integer>>() {};
40+ private static final TypeToken<NumberBox<Long>> NUMBERBOX_OF_LONG_TOKEN = new TypeToken<NumberBox<Long>>() {};
41+ private static final TypeToken<NumberBox<Float>> NUMBERBOX_OF_FLOAT_TOKEN = new TypeToken<NumberBox<Float>>() {};
42+ private static final TypeToken<NumberBox<Double>> NUMBERBOX_OF_DOUBLE_TOKEN = new TypeToken<NumberBox<Double>>() {};
43+ private static final TypeToken<NumberBox<BigInteger>> NUMBERBOX_OF_BIGINTEGER_TOKEN = new TypeToken<NumberBox<BigInteger>>() {};
44+ private static final TypeToken<NumberBox<BigDecimal>> NUMBERBOX_OF_BIGDECIMAL_TOKEN = new TypeToken<NumberBox<BigDecimal>>() {};
45+ // @formatter:on
46+
3847 private final String insertQuery = "INSERT INTO \"myTable\" (c_int, c_bigint, c_float, c_double, c_varint, c_decimal) VALUES (?, ?, ?, ?, ?, ?)";
3948
4049 private final String selectQuery = "SELECT c_int, c_bigint, c_float, c_double, c_varint, c_decimal FROM \"myTable\" WHERE c_int = ? and c_bigint = ?";
@@ -127,25 +136,17 @@
127136 @Test(groups = "short")
128137 public void should_use_custom_codecs_with_prepared_statements_2() {
129138 session.execute(session.prepare(insertQuery).bind()
130- .set(0, new NumberBox<Integer>(n_int), new TypeToken<NumberBox<Integer>>() {
131- })
132- .set(1, new NumberBox<Long>(n_bigint), new TypeToken<NumberBox<Long>>() {
133- })
134- .set(2, new NumberBox<Float>(n_float), new TypeToken<NumberBox<Float>>() {
135- })
136- .set(3, new NumberBox<Double>(n_double), new TypeToken<NumberBox<Double>>() {
137- })
138- .set(4, new NumberBox<BigInteger>(n_varint), new TypeToken<NumberBox<BigInteger>>() {
139- })
140- .set(5, new NumberBox<BigDecimal>(n_decimal), new TypeToken<NumberBox<BigDecimal>>() {
141- })
139+ .set(0, new NumberBox<Integer>(n_int), NUMBERBOX_OF_INTEGER_TOKEN)
140+ .set(1, new NumberBox<Long>(n_bigint), NUMBERBOX_OF_LONG_TOKEN)
141+ .set(2, new NumberBox<Float>(n_float), NUMBERBOX_OF_FLOAT_TOKEN)
142+ .set(3, new NumberBox<Double>(n_double), NUMBERBOX_OF_DOUBLE_TOKEN)
143+ .set(4, new NumberBox<BigInteger>(n_varint), NUMBERBOX_OF_BIGINTEGER_TOKEN)
144+ .set(5, new NumberBox<BigDecimal>(n_decimal), NUMBERBOX_OF_BIGDECIMAL_TOKEN)
142145 );
143146 PreparedStatement ps = session.prepare(selectQuery);
144147 ResultSet rows = session.execute(ps.bind()
145- .set(0, new NumberBox<Integer>(n_int), new TypeToken<NumberBox<Integer>>() {
146- })
147- .set(1, new NumberBox<Long>(n_bigint), new TypeToken<NumberBox<Long>>() {
148- })
148+ .set(0, new NumberBox<Integer>(n_int), NUMBERBOX_OF_INTEGER_TOKEN)
149+ .set(1, new NumberBox<Long>(n_bigint), NUMBERBOX_OF_LONG_TOKEN)
149150 );
150151 Row row = rows.one();
151152 assertRow(row);
@@ -169,26 +170,17 @@
169170 @Test(groups = "short")
170171 public void should_use_custom_codecs_with_built_statements_2() {
171172 session.execute(session.prepare(insertStmt).bind()
172- .set(0, new NumberBox<Integer>(n_int), new TypeToken<NumberBox<Integer>>() {
173- })
174- .set(1, new NumberBox<Long>(n_bigint), new TypeToken<NumberBox<Long>>() {
175- })
176- .set(2, new NumberBox<Float>(n_float), new TypeToken<NumberBox<Float>>() {
177- })
178- .set(3, new NumberBox<Double>(n_double), new TypeToken<NumberBox<Double>>() {
179- })
180- .set(4, new NumberBox<BigInteger>(n_varint), new TypeToken<NumberBox<BigInteger>>() {
181- })
182- .set(5, new NumberBox<BigDecimal>(n_decimal), new TypeToken<NumberBox<BigDecimal>>() {
183- })
184- );
173+ .set(0, new NumberBox<Integer>(n_int), NUMBERBOX_OF_INTEGER_TOKEN)
174+ .set(1, new NumberBox<Long>(n_bigint), NUMBERBOX_OF_LONG_TOKEN)
175+ .set(2, new NumberBox<Float>(n_float), NUMBERBOX_OF_FLOAT_TOKEN)
176+ .set(3, new NumberBox<Double>(n_double), NUMBERBOX_OF_DOUBLE_TOKEN)
177+ .set(4, new NumberBox<BigInteger>(n_varint), NUMBERBOX_OF_BIGINTEGER_TOKEN)
178+ .set(5, new NumberBox<BigDecimal>(n_decimal), NUMBERBOX_OF_BIGDECIMAL_TOKEN));
185179 PreparedStatement ps = session.prepare(selectStmt);
186180 ResultSet rows = session.execute(ps.bind()
187- .set(0, new NumberBox<Integer>(n_int), new TypeToken<NumberBox<Integer>>() {
188- })
189- .set(1, new NumberBox<Long>(n_bigint), new TypeToken<NumberBox<Long>>() {
190- })
191- );
181+ .set(0, new NumberBox<Integer>(n_int), NUMBERBOX_OF_INTEGER_TOKEN)
182+ .set(1, new NumberBox<Long>(n_bigint), NUMBERBOX_OF_LONG_TOKEN));
183+
192184 Row row = rows.one();
193185 assertRow(row);
194186 }
@@ -219,18 +211,12 @@
219211 assertThat(row.get(5, BigDecimal.class)).isEqualTo(n_decimal);
220212 // with get + type, but enforcing NumberBox types
221213 // we get the NumberBox codecs instead
222- assertThat(row.get(0, new TypeToken<NumberBox<Integer>>() {
223- })).isEqualTo(new NumberBox<Integer>(n_int));
224- assertThat(row.get(1, new TypeToken<NumberBox<Long>>() {
225- })).isEqualTo(new NumberBox<Long>(n_bigint));
226- assertThat(row.get(2, new TypeToken<NumberBox<Float>>() {
227- })).isEqualTo(new NumberBox<Float>(n_float));
228- assertThat(row.get(3, new TypeToken<NumberBox<Double>>() {
229- })).isEqualTo(new NumberBox<Double>(n_double));
230- assertThat(row.get(4, new TypeToken<NumberBox<BigInteger>>() {
231- })).isEqualTo(new NumberBox<BigInteger>(n_varint));
232- assertThat(row.get(5, new TypeToken<NumberBox<BigDecimal>>() {
233- })).isEqualTo(new NumberBox<BigDecimal>(n_decimal));
214+ assertThat(row.get(0, NUMBERBOX_OF_INTEGER_TOKEN)).isEqualTo(new NumberBox<Integer>(n_int));
215+ assertThat(row.get(1, NUMBERBOX_OF_LONG_TOKEN)).isEqualTo(new NumberBox<Long>(n_bigint));
216+ assertThat(row.get(2, NUMBERBOX_OF_FLOAT_TOKEN)).isEqualTo(new NumberBox<Float>(n_float));
217+ assertThat(row.get(3, NUMBERBOX_OF_DOUBLE_TOKEN)).isEqualTo(new NumberBox<Double>(n_double));
218+ assertThat(row.get(4, NUMBERBOX_OF_BIGINTEGER_TOKEN)).isEqualTo(new NumberBox<BigInteger>(n_varint));
219+ assertThat(row.get(5, NUMBERBOX_OF_BIGDECIMAL_TOKEN)).isEqualTo(new NumberBox<BigDecimal>(n_decimal));
234220 }
235221
236222 private class NumberBoxCodec<T extends Number> extends TypeCodec<NumberBox<T>> {
@@ -238,9 +224,10 @@
238224 private final TypeCodec<T> numberCodec;
239225
240226 protected NumberBoxCodec(TypeCodec<T> numberCodec) {
241- super(numberCodec.getCqlType(), new TypeToken<NumberBox<T>>() {
242- }.where(new TypeParameter<T>() {
243- }, numberCodec.getJavaType()));
227+ // @formatter:off
228+ super(numberCodec.getCqlType(),
229+ new TypeToken<NumberBox<T>>() {}.where(new TypeParameter<T>() {}, numberCodec.getJavaType()));
230+ // @formatter:on
244231 this.numberCodec = numberCodec;
245232 }
246233
modified driver-core/src/test/java/com/datastax/driver/core/TypeCodecNestedCollectionsIntegrationTest.java +4 −4
@@ -49,10 +49,10 @@
4949 private int pk = 42;
5050 private List<Set<Map<MyInt, String>>> v;
5151
52- private TypeToken<List<Set<Map<MyInt, String>>>> listType = new TypeToken<List<Set<Map<MyInt, String>>>>() {
53- };
54- private TypeToken<Set<Map<MyInt, String>>> elementsType = new TypeToken<Set<Map<MyInt, String>>>() {
55- };
52+ // @formatter:off
53+ private TypeToken<List<Set<Map<MyInt, String>>>> listType = new TypeToken<List<Set<Map<MyInt, String>>>>() {};
54+ private TypeToken<Set<Map<MyInt, String>>> elementsType = new TypeToken<Set<Map<MyInt, String>>>() {};
55+ // @formatter:on
5656
5757 @Override
5858 protected Collection<String> getTableDefinitions() {
modified driver-core/src/test/java/com/datastax/driver/core/TypeCodecOverlappingJavaTypeIntegrationTest.java +2 −6
@@ -16,12 +16,10 @@
1616 package com.datastax.driver.core;
1717
1818 import com.datastax.driver.core.exceptions.InvalidTypeException;
19-import com.google.common.reflect.TypeToken;
2019 import org.testng.annotations.Test;
2120
2221 import java.nio.ByteBuffer;
2322 import java.util.Collection;
24-import java.util.List;
2523
2624 import static com.google.common.collect.Lists.newArrayList;
2725 import static org.assertj.core.api.Assertions.assertThat;
@@ -84,10 +82,8 @@
8482 assertThat(row.getList(1, Integer.class)).isEqualTo(newArrayList(42));
8583 assertThat(row.getList(1, String.class)).isEqualTo(newArrayList("42"));
8684 assertThat(row.getObject(1)).isEqualTo(newArrayList(42)); // uses the default codec
87- assertThat(row.get(1, new TypeToken<List<Integer>>() {
88- })).isEqualTo(newArrayList(42));
89- assertThat(row.get(1, new TypeToken<List<String>>() {
90- })).isEqualTo(newArrayList("42"));
85+ assertThat(row.get(1, TypeTokens.listOf(Integer.class))).isEqualTo(newArrayList(42));
86+ assertThat(row.get(1, TypeTokens.listOf(String.class))).isEqualTo(newArrayList("42"));
9187 }
9288
9389 private class IntToStringCodec extends TypeCodec<String> {
modified driver-core/src/test/java/com/datastax/driver/core/TypeCodecTest.java +9 −8
@@ -38,6 +38,11 @@
3838
3939 public static final DataType CUSTOM_FOO = DataType.custom("com.example.FooBar");
4040
41+ // @formatter:off
42+ public static final TypeToken<List<A>> LIST_OF_A_TOKEN = new TypeToken<List<A>>() {};
43+ public static final TypeToken<List<B>> LIST_OF_B_TOKEN = new TypeToken<List<B>>() {};
44+ // @formatter:on
45+
4146 private CodecRegistry codecRegistry = new CodecRegistry();
4247
4348 @Test(groups = "unit")
@@ -167,14 +172,12 @@
167172 //ok
168173 }
169174 TypeCodec<List<A>> expected = TypeCodec.list(aCodec);
170- TypeCodec<List<A>> actual = codecRegistry.codecFor(list(cint()), new TypeToken<List<A>>() {
171- });
175+ TypeCodec<List<A>> actual = codecRegistry.codecFor(list(cint()), LIST_OF_A_TOKEN);
172176 assertThat(actual.getCqlType()).isEqualTo(expected.getCqlType());
173177 assertThat(actual.getJavaType()).isEqualTo(expected.getJavaType());
174178 // cannot work: List<B> is not assignable to List<A>
175179 try {
176- codecRegistry.codecFor(list(cint()), new TypeToken<List<B>>() {
177- });
180+ codecRegistry.codecFor(list(cint()), LIST_OF_B_TOKEN);
178181 fail();
179182 } catch (CodecNotFoundException e) {
180183 //ok
@@ -190,15 +193,13 @@
190193 }
191194 assertThat(codecRegistry.codecFor(cint(), B.class)).isNotNull().isSameAs(bCodec);
192195 try {
193- codecRegistry.codecFor(list(cint()), new TypeToken<List<A>>() {
194- });
196+ codecRegistry.codecFor(list(cint()), LIST_OF_A_TOKEN);
195197 fail();
196198 } catch (CodecNotFoundException e) {
197199 // ok
198200 }
199201 TypeCodec<List<B>> expectedB = TypeCodec.list(bCodec);
200- TypeCodec<List<B>> actualB = codecRegistry.codecFor(list(cint()), new TypeToken<List<B>>() {
201- });
202+ TypeCodec<List<B>> actualB = codecRegistry.codecFor(list(cint()), LIST_OF_B_TOKEN);
202203 assertThat(actualB.getCqlType()).isEqualTo(expectedB.getCqlType());
203204 assertThat(actualB.getJavaType()).isEqualTo(expectedB.getJavaType());
204205 }
modified driver-extras/src/main/java/com/datastax/driver/extras/codecs/guava/OptionalCodec.java +3 −3
@@ -46,9 +46,9 @@
4646 }
4747
4848 public OptionalCodec(TypeCodec<T> codec, Predicate<T> isAbsent) {
49- super(codec, new TypeToken<Optional<T>>() {
50- }.where(new TypeParameter<T>() {
51- }, codec.getJavaType()));
49+ // @formatter:off
50+ super(codec, new TypeToken<Optional<T>>() {}.where(new TypeParameter<T>() {}, codec.getJavaType()));
51+ // @formatter:on
5252 this.isAbsent = isAbsent;
5353 }
5454
modified driver-extras/src/main/java/com/datastax/driver/extras/codecs/jdk8/OptionalCodec.java +3 −3
@@ -47,9 +47,9 @@
4747 }
4848
4949 public OptionalCodec(TypeCodec<T> codec, Predicate<T> isAbsent) {
50- super(codec, new TypeToken<Optional<T>>() {
51- }.where(new TypeParameter<T>() {
52- }, codec.getJavaType()));
50+ // @formatter:off
51+ super(codec, new TypeToken<Optional<T>>() {}.where(new TypeParameter<T>() {}, codec.getJavaType()));
52+ // @formatter:on
5353 this.isAbsent = isAbsent;
5454 }
5555
modified driver-extras/src/test/java/com/datastax/driver/extras/codecs/enums/EnumCodecsTest.java +9 −19
@@ -21,7 +21,6 @@
2121 import com.datastax.driver.mapping.MappingManager;
2222 import com.datastax.driver.mapping.annotations.*;
2323 import com.google.common.collect.ImmutableMap;
24-import com.google.common.reflect.TypeToken;
2524 import org.testng.annotations.BeforeMethod;
2625 import org.testng.annotations.Test;
2726
@@ -124,8 +123,7 @@
124123 .set(1, FOO_1, Foo.class)
125124 .setList(2, foos, Foo.class)
126125 .set(3, BAR_1, Bar.class)
127- .set(4, bars, new TypeToken<Set<Bar>>() {
128- })
126+ .set(4, bars, TypeTokens.setOf(Bar.class))
129127 .setMap(5, foobars, Foo.class, Bar.class)
130128 .setTupleValue(6, tupleValue)
131129 .setUDTValue(7, udtValue)
@@ -199,10 +197,8 @@
199197 assertThat(row.getObject(2)).isEqualTo(newArrayList(FOO_1.ordinal(), FOO_2.ordinal())); // uses the built-in ListCodec(IntCodec) because CQL type is list<int>
200198 assertThat(row.getList(2, Integer.class)).isEqualTo(newArrayList(FOO_1.ordinal(), FOO_2.ordinal()));
201199 assertThat(row.getList("foos", Foo.class)).isEqualTo(newArrayList(FOO_1, FOO_2));
202- assertThat(row.get(2, new TypeToken<List<Integer>>() {
203- })).isEqualTo(newArrayList(FOO_1.ordinal(), FOO_2.ordinal()));
204- assertThat(row.get("foos", new TypeToken<List<Foo>>() {
205- })).isEqualTo(newArrayList(FOO_1, FOO_2));
200+ assertThat(row.get(2, TypeTokens.listOf(Integer.class))).isEqualTo(newArrayList(FOO_1.ordinal(), FOO_2.ordinal()));
201+ assertThat(row.get("foos", TypeTokens.listOf(Foo.class))).isEqualTo(newArrayList(FOO_1, FOO_2));
206202
207203 assertThat(row.getObject(3)).isEqualTo(BAR_1.name()); // uses the built-in VarcharCodec because CQL type is varchar
208204 assertThat(row.getString("bar")).isEqualTo(BAR_1.name()); // forces VarcharCodec
@@ -212,10 +208,8 @@
212208 assertThat(row.getObject(4)).isEqualTo(newHashSet(BAR_1.name(), BAR_2.name())); // uses the built-in SetCodec(VarcharCodec) because CQL type is set<varchar>
213209 assertThat(row.getSet(4, String.class)).isEqualTo(newHashSet(BAR_1.name(), BAR_2.name()));
214210 assertThat(row.getSet("bars", Bar.class)).isEqualTo(newHashSet(BAR_1, BAR_2));
215- assertThat(row.get(4, new TypeToken<Set<String>>() {
216- })).isEqualTo(newHashSet(BAR_1.name(), BAR_2.name()));
217- assertThat(row.get("bars", new TypeToken<Set<Bar>>() {
218- })).isEqualTo(newHashSet(BAR_1, BAR_2));
211+ assertThat(row.get(4, TypeTokens.setOf(String.class))).isEqualTo(newHashSet(BAR_1.name(), BAR_2.name()));
212+ assertThat(row.get("bars", TypeTokens.setOf(Bar.class))).isEqualTo(newHashSet(BAR_1, BAR_2));
219213
220214 // uses default built-in codec MapCodec(IntCodec, VarcharCodec) because CQL type is map<int, varchar>
221215 assertThat(row.getObject(5)).isEqualTo(ImmutableMap.of(FOO_1.ordinal(), BAR_1.name(), FOO_2.ordinal(), BAR_2.name()));
@@ -227,14 +221,10 @@
227221 assertThat(row.getMap(5, Foo.class, Bar.class)).isEqualTo(ImmutableMap.of(FOO_1, BAR_1, FOO_2, BAR_2));
228222
229223 // get + TypeToken with combinations of built-in or EnumX codecs
230- assertThat(row.get("foobars", new TypeToken<Map<Integer, String>>() {
231- })).isEqualTo(ImmutableMap.of(FOO_1.ordinal(), BAR_1.name(), FOO_2.ordinal(), BAR_2.name()));
232- assertThat(row.get("foobars", new TypeToken<Map<Foo, String>>() {
233- })).isEqualTo(ImmutableMap.of(FOO_1, BAR_1.name(), FOO_2, BAR_2.name()));
234- assertThat(row.get("foobars", new TypeToken<Map<Integer, Bar>>() {
235- })).isEqualTo(ImmutableMap.of(FOO_1.ordinal(), BAR_1, FOO_2.ordinal(), BAR_2));
236- assertThat(row.get("foobars", new TypeToken<Map<Foo, Bar>>() {
237- })).isEqualTo(ImmutableMap.of(FOO_1, BAR_1, FOO_2, BAR_2));
224+ assertThat(row.get("foobars", TypeTokens.mapOf(Integer.class, String.class))).isEqualTo(ImmutableMap.of(FOO_1.ordinal(), BAR_1.name(), FOO_2.ordinal(), BAR_2.name()));
225+ assertThat(row.get("foobars", TypeTokens.mapOf(Foo.class, String.class))).isEqualTo(ImmutableMap.of(FOO_1, BAR_1.name(), FOO_2, BAR_2.name()));
226+ assertThat(row.get("foobars", TypeTokens.mapOf(Integer.class, Bar.class))).isEqualTo(ImmutableMap.of(FOO_1.ordinal(), BAR_1, FOO_2.ordinal(), BAR_2));
227+ assertThat(row.get("foobars", TypeTokens.mapOf(Foo.class, Bar.class))).isEqualTo(ImmutableMap.of(FOO_1, BAR_1, FOO_2, BAR_2));
238228
239229 assertThat(row.getTupleValue(6).getInt(0)).isEqualTo(FOO_1.ordinal());
240230 assertThat(row.get(6, TupleValue.class).get(0, Foo.class)).isEqualTo(FOO_1);
modified driver-mapping/src/test/java/com/datastax/driver/mapping/MapperCustomCodecTest.java +4 −3
@@ -567,9 +567,10 @@
567567 private final Predicate<T> isAbsent;
568568
569569 public OptionalCodec(TypeCodec<T> codec) {
570- super(codec, new TypeToken<Optional<T>>() {
571- }.where(new TypeParameter<T>() {
572- }, codec.getJavaType()));
570+ // @formatter:off
571+ super(codec,
572+ new TypeToken<Optional<T>>() {}.where(new TypeParameter<T>() {}, codec.getJavaType()));
573+ // @formatter:on
573574 this.isAbsent = new Predicate<T>() {
574575 @Override
575576 public boolean apply(T input) {