refactoring

pull/4344/head
Nikita Koksharov 3 years ago
parent e27d87ca15
commit 84d82a1390

@ -136,7 +136,16 @@ public class JsonJacksonCodec extends BaseCodec {
} }
public JsonJacksonCodec(ObjectMapper mapObjectMapper) { public JsonJacksonCodec(ObjectMapper mapObjectMapper) {
this.mapObjectMapper = mapObjectMapper.copy(); this(mapObjectMapper, true);
warmup();
}
public JsonJacksonCodec(ObjectMapper mapObjectMapper, boolean copy) {
if (copy) {
this.mapObjectMapper = mapObjectMapper.copy();
} else {
this.mapObjectMapper = mapObjectMapper;
}
init(this.mapObjectMapper); init(this.mapObjectMapper);
initTypeInclusion(this.mapObjectMapper); initTypeInclusion(this.mapObjectMapper);
warmup(); warmup();

@ -83,7 +83,8 @@ public class TypedJsonJacksonCodec extends JsonJacksonCodec {
private final Class<?> mapValueClass; private final Class<?> mapValueClass;
public TypedJsonJacksonCodec(Class<?> valueClass) { public TypedJsonJacksonCodec(Class<?> valueClass) {
this(valueClass, new ObjectMapper()); this(null, null, null,
valueClass, null, null, new ObjectMapper(), false);
} }
public TypedJsonJacksonCodec(Class<?> valueClass, ObjectMapper mapper) { public TypedJsonJacksonCodec(Class<?> valueClass, ObjectMapper mapper) {
@ -99,11 +100,13 @@ public class TypedJsonJacksonCodec extends JsonJacksonCodec {
} }
public TypedJsonJacksonCodec(Class<?> valueClass, Class<?> mapKeyClass, Class<?> mapValueClass) { public TypedJsonJacksonCodec(Class<?> valueClass, Class<?> mapKeyClass, Class<?> mapValueClass) {
this(null, null, null, valueClass, mapKeyClass, mapValueClass, new ObjectMapper()); this(null, null, null,
valueClass, mapKeyClass, mapValueClass, new ObjectMapper(), false);
} }
public TypedJsonJacksonCodec(Class<?> valueClass, Class<?> mapKeyClass, Class<?> mapValueClass, ObjectMapper mapper) { public TypedJsonJacksonCodec(Class<?> valueClass, Class<?> mapKeyClass, Class<?> mapValueClass, ObjectMapper mapper) {
this(null, null, null, valueClass, mapKeyClass, mapValueClass, mapper); this(null, null, null,
valueClass, mapKeyClass, mapValueClass, mapper, true);
} }
public TypedJsonJacksonCodec(TypeReference<?> valueTypeReference) { public TypedJsonJacksonCodec(TypeReference<?> valueTypeReference) {
@ -123,23 +126,24 @@ public class TypedJsonJacksonCodec extends JsonJacksonCodec {
} }
public TypedJsonJacksonCodec(TypeReference<?> valueTypeReference, TypeReference<?> mapKeyTypeReference, TypeReference<?> mapValueTypeReference) { public TypedJsonJacksonCodec(TypeReference<?> valueTypeReference, TypeReference<?> mapKeyTypeReference, TypeReference<?> mapValueTypeReference) {
this(valueTypeReference, mapKeyTypeReference, mapValueTypeReference, null, null, null, new ObjectMapper()); this(valueTypeReference, mapKeyTypeReference, mapValueTypeReference,
null, null, null, new ObjectMapper(), false);
} }
public TypedJsonJacksonCodec(TypeReference<?> valueTypeReference, TypeReference<?> mapKeyTypeReference, TypeReference<?> mapValueTypeReference, ObjectMapper mapper) { public TypedJsonJacksonCodec(TypeReference<?> valueTypeReference, TypeReference<?> mapKeyTypeReference, TypeReference<?> mapValueTypeReference, ObjectMapper mapper) {
this(valueTypeReference, mapKeyTypeReference, mapValueTypeReference, null, null, null, mapper); this(valueTypeReference, mapKeyTypeReference, mapValueTypeReference,
null, null, null, mapper, true);
} }
public TypedJsonJacksonCodec(ClassLoader classLoader, TypedJsonJacksonCodec codec) { public TypedJsonJacksonCodec(ClassLoader classLoader, TypedJsonJacksonCodec codec) {
this(codec.valueTypeReference, codec.mapKeyTypeReference, codec.mapValueTypeReference, this(codec.valueTypeReference, codec.mapKeyTypeReference, codec.mapValueTypeReference,
codec.valueClass, codec.mapKeyClass, codec.mapValueClass, codec.valueClass, codec.mapKeyClass, codec.mapValueClass,
createObjectMapper(classLoader, codec.mapObjectMapper.copy())); createObjectMapper(classLoader, codec.mapObjectMapper.copy()), false);
} }
TypedJsonJacksonCodec( TypedJsonJacksonCodec(TypeReference<?> valueTypeReference, TypeReference<?> mapKeyTypeReference, TypeReference<?> mapValueTypeReference,
TypeReference<?> valueTypeReference, TypeReference<?> mapKeyTypeReference, TypeReference<?> mapValueTypeReference, Class<?> valueClass, Class<?> mapKeyClass, Class<?> mapValueClass, ObjectMapper mapper, boolean copy) {
Class<?> valueClass, Class<?> mapKeyClass, Class<?> mapValueClass, ObjectMapper mapper) { super(mapper, copy);
super(mapper);
this.mapValueDecoder = createDecoder(mapValueClass, mapValueTypeReference); this.mapValueDecoder = createDecoder(mapValueClass, mapValueTypeReference);
this.mapKeyDecoder = createDecoder(mapKeyClass, mapKeyTypeReference); this.mapKeyDecoder = createDecoder(mapKeyClass, mapKeyTypeReference);
this.valueDecoder = createDecoder(valueClass, valueTypeReference); this.valueDecoder = createDecoder(valueClass, valueTypeReference);

Loading…
Cancel
Save