@Test public void testMapJsonCodec() { JsonCodec<Map<String, Person>> jsonCodec = jsonCodecFactory.mapJsonCodec(String.class, Person.class); validateMapCodec(jsonCodec); }
public <K, V> JsonCodec<Map<K, V>> mapJsonCodec(Class<K> keyType, Class<V> valueType) { requireNonNull(keyType, "keyType is null"); requireNonNull(valueType, "valueType is null"); Type mapType = new TypeToken<Map<K, V>>() {} .where(new TypeParameter<K>() {}, keyType) .where(new TypeParameter<V>() {}, valueType) .getType(); return new JsonCodec<>(createObjectMapper(), mapType); }
JsonCodecFactory { public <K, V> JsonCodec<Map<K, V>> mapJsonCodec(Class<K> keyType, Class<V> valueType) { requireNonNull(keyType, "keyType is null"); requireNonNull(valueType, "valueType is null"); Type mapType = new TypeToken<Map<K, V>>() {} .where(new TypeParameter<K>() {}, keyType) .where(new TypeParameter<V>() {}, valueType) .getType(); return new JsonCodec<>(createObjectMapper(), mapType); } }
JsonCodecFactory { public <K, V> JsonCodec<Map<K, V>> mapJsonCodec(Class<K> keyType, Class<V> valueType) { requireNonNull(keyType, "keyType is null"); requireNonNull(valueType, "valueType is null"); Type mapType = new TypeToken<Map<K, V>>() {} .where(new TypeParameter<K>() {}, keyType) .where(new TypeParameter<V>() {}, valueType) .getType(); return new JsonCodec<>(createObjectMapper(), mapType); } JsonCodecFactory(); @Inject  JsonCodecFactory(Provider<ObjectMapper> objectMapperProvider);  JsonCodecFactory(Provider<ObjectMapper> objectMapperProvider, boolean prettyPrint); }
JsonCodecFactory { public <K, V> JsonCodec<Map<K, V>> mapJsonCodec(Class<K> keyType, Class<V> valueType) { requireNonNull(keyType, "keyType is null"); requireNonNull(valueType, "valueType is null"); Type mapType = new TypeToken<Map<K, V>>() {} .where(new TypeParameter<K>() {}, keyType) .where(new TypeParameter<V>() {}, valueType) .getType(); return new JsonCodec<>(createObjectMapper(), mapType); } JsonCodecFactory(); @Inject  JsonCodecFactory(Provider<ObjectMapper> objectMapperProvider);  JsonCodecFactory(Provider<ObjectMapper> objectMapperProvider, boolean prettyPrint); JsonCodecFactory prettyPrint(); JsonCodec<T> jsonCodec(Class<T> type); JsonCodec<T> jsonCodec(Type type); JsonCodec<T> jsonCodec(TypeToken<T> type); JsonCodec<List<T>> listJsonCodec(Class<T> type); JsonCodec<List<T>> listJsonCodec(JsonCodec<T> type); JsonCodec<Map<K, V>> mapJsonCodec(Class<K> keyType, Class<V> valueType); JsonCodec<Map<K, V>> mapJsonCodec(Class<K> keyType, JsonCodec<V> valueType); }
JsonCodecFactory { public <K, V> JsonCodec<Map<K, V>> mapJsonCodec(Class<K> keyType, Class<V> valueType) { requireNonNull(keyType, "keyType is null"); requireNonNull(valueType, "valueType is null"); Type mapType = new TypeToken<Map<K, V>>() {} .where(new TypeParameter<K>() {}, keyType) .where(new TypeParameter<V>() {}, valueType) .getType(); return new JsonCodec<>(createObjectMapper(), mapType); } JsonCodecFactory(); @Inject  JsonCodecFactory(Provider<ObjectMapper> objectMapperProvider);  JsonCodecFactory(Provider<ObjectMapper> objectMapperProvider, boolean prettyPrint); JsonCodecFactory prettyPrint(); JsonCodec<T> jsonCodec(Class<T> type); JsonCodec<T> jsonCodec(Type type); JsonCodec<T> jsonCodec(TypeToken<T> type); JsonCodec<List<T>> listJsonCodec(Class<T> type); JsonCodec<List<T>> listJsonCodec(JsonCodec<T> type); JsonCodec<Map<K, V>> mapJsonCodec(Class<K> keyType, Class<V> valueType); JsonCodec<Map<K, V>> mapJsonCodec(Class<K> keyType, JsonCodec<V> valueType);  }