Skip to content

Commit 8d1c9c8

Browse files
committed
Trying to make TypeResolverProvider overridable
1 parent ea9c999 commit 8d1c9c8

File tree

13 files changed

+208
-489
lines changed

13 files changed

+208
-489
lines changed

src/main/java/com/fasterxml/jackson/databind/DeserializationConfig.java

Lines changed: 3 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -75,22 +75,6 @@ public final class DeserializationConfig
7575
/**********************************************************************
7676
*/
7777

78-
/**
79-
* Copy-constructor used for making a copy used by new {@link ObjectMapper}.
80-
*/
81-
/*
82-
protected DeserializationConfig(DeserializationConfig src,
83-
MixInHandler mixins, RootNameLookup rootNames,
84-
ConfigOverrides configOverrides)
85-
{
86-
super(src, mixins, rootNames, configOverrides);
87-
_deserFeatures = src._deserFeatures;
88-
_problemHandlers = src._problemHandlers;
89-
_parserFeatures = src._parserFeatures;
90-
_formatParserFeatures = src._formatParserFeatures;
91-
}
92-
*/
93-
9478
/**
9579
* @since 3.0
9680
*/
@@ -99,9 +83,7 @@ public DeserializationConfig(MapperBuilder<?,?> b, int mapperFeatures,
9983
MixInHandler mixins, RootNameLookup rootNames, ConfigOverrides configOverrides,
10084
AbstractTypeResolver[] atrs)
10185
{
102-
super(b.baseSettings(), mapperFeatures,
103-
b.classIntrospector(), b.subtypeResolver(),
104-
mixins, rootNames, configOverrides);
86+
super(b, mapperFeatures, mixins, rootNames, configOverrides);
10587
_deserFeatures = deserFeatures;
10688
_parserFeatures = parserFeatures;
10789
_formatParserFeatures = formatParserFeatures;
@@ -127,20 +109,6 @@ private DeserializationConfig(DeserializationConfig src,
127109
_problemHandlers = src._problemHandlers;
128110
_abstractTypeResolvers = src._abstractTypeResolvers;
129111
}
130-
131-
/**
132-
* Copy constructor used to create a non-shared instance with given mix-in
133-
* annotation definitions and subtype resolver.
134-
*/
135-
private DeserializationConfig(DeserializationConfig src, SubtypeResolver str)
136-
{
137-
super(src, str);
138-
_deserFeatures = src._deserFeatures;
139-
_parserFeatures = src._parserFeatures;
140-
_formatParserFeatures = src._formatParserFeatures;
141-
_problemHandlers = src._problemHandlers;
142-
_abstractTypeResolvers = src._abstractTypeResolvers;
143-
}
144112

145113
private DeserializationConfig(DeserializationConfig src, BaseSettings base)
146114
{
@@ -194,16 +162,6 @@ protected DeserializationConfig(DeserializationConfig src, ContextAttributes att
194162
_abstractTypeResolvers = src._abstractTypeResolvers;
195163
}
196164

197-
protected DeserializationConfig(DeserializationConfig src, MixInHandler mixins)
198-
{
199-
super(src, mixins);
200-
_deserFeatures = src._deserFeatures;
201-
_problemHandlers = src._problemHandlers;
202-
_parserFeatures = src._parserFeatures;
203-
_formatParserFeatures = src._formatParserFeatures;
204-
_abstractTypeResolvers = src._abstractTypeResolvers;
205-
}
206-
207165
// for unit tests only:
208166
protected BaseSettings getBaseSettings() { return _base; }
209167

@@ -230,11 +188,6 @@ protected final DeserializationConfig _withMapperFeatures(int mapperFeatures) {
230188
/**********************************************************************
231189
*/
232190

233-
@Override
234-
public DeserializationConfig with(SubtypeResolver str) {
235-
return (_subtypeResolver == str) ? this : new DeserializationConfig(this, str);
236-
}
237-
238191
@Override
239192
public DeserializationConfig withRootName(PropertyName rootName) {
240193
if (rootName == null) {
@@ -410,9 +363,9 @@ public DeserializationConfig withoutFeatures(JsonParser.Feature... features)
410363
}
411364

412365
/*
413-
/**********************************************************
366+
/**********************************************************************
414367
/* Life-cycle, JsonParser.FormatFeature-based factory methods
415-
/**********************************************************
368+
/**********************************************************************
416369
*/
417370

418371
/**

src/main/java/com/fasterxml/jackson/databind/ObjectReader.java

Lines changed: 48 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ public class ObjectReader
4848
protected final static JavaType JSON_NODE_TYPE = SimpleType.constructUnsafe(JsonNode.class);
4949

5050
/*
51-
/**********************************************************
51+
/**********************************************************************
5252
/* Immutable configuration from ObjectMapper
53-
/**********************************************************
53+
/**********************************************************************
5454
*/
5555

5656
/**
@@ -80,11 +80,11 @@ public class ObjectReader
8080
* Default value to be null as filter not considered.
8181
*/
8282
private final TokenFilter _filter;
83-
83+
8484
/*
85-
/**********************************************************
85+
/**********************************************************************
8686
/* Configuration that can be changed during building
87-
/**********************************************************
87+
/**********************************************************************
8888
*/
8989

9090
/**
@@ -127,9 +127,9 @@ public class ObjectReader
127127
protected final InjectableValues _injectableValues;
128128

129129
/*
130-
/**********************************************************
130+
/**********************************************************************
131131
/* Caching
132-
/**********************************************************
132+
/**********************************************************************
133133
*/
134134

135135
/**
@@ -139,9 +139,9 @@ public class ObjectReader
139139
final protected ConcurrentHashMap<JavaType, JsonDeserializer<Object>> _rootDeserializers;
140140

141141
/*
142-
/**********************************************************
142+
/**********************************************************************
143143
/* Life-cycle, construction
144-
/**********************************************************
144+
/**********************************************************************
145145
*/
146146

147147
/**
@@ -214,26 +214,7 @@ protected ObjectReader(ObjectReader base, DeserializationConfig config)
214214
_unwrapRoot = config.useRootWrapping();
215215
_filter = base._filter;
216216
}
217-
218-
protected ObjectReader(ObjectReader base, TokenStreamFactory f)
219-
{
220-
// may need to override ordering, based on data format capabilities
221-
_config = base._config
222-
.with(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY, f.requiresPropertyOrdering());
223-
_context = base._context;
224217

225-
_rootDeserializers = base._rootDeserializers;
226-
_parserFactory = f;
227-
228-
_valueType = base._valueType;
229-
_rootDeserializer = base._rootDeserializer;
230-
_valueToUpdate = base._valueToUpdate;
231-
_schema = base._schema;
232-
_injectableValues = base._injectableValues;
233-
_unwrapRoot = base._unwrapRoot;
234-
_filter = base._filter;
235-
}
236-
237218
protected ObjectReader(ObjectReader base, TokenFilter filter) {
238219
_config = base._config;
239220
_context = base._context;
@@ -258,11 +239,11 @@ public Version version() {
258239
}
259240

260241
/*
261-
/**********************************************************
242+
/**********************************************************************
262243
/* Helper methods used internally for invoking constructors
263244
/* Need to be overridden if sub-classing (not recommended)
264245
/* is used.
265-
/**********************************************************
246+
/**********************************************************************
266247
*/
267248

268249
/**
@@ -294,9 +275,9 @@ protected <T> MappingIterator<T> _newIterator(JsonParser p, DeserializationConte
294275
}
295276

296277
/*
297-
/**********************************************************
278+
/**********************************************************************
298279
/* Methods for initializing parser instance to use
299-
/**********************************************************
280+
/**********************************************************************
300281
*/
301282

302283
protected JsonToken _initForReading(DefaultDeserializationContext ctxt, JsonParser p)
@@ -333,9 +314,9 @@ protected void _initForMultiRead(DefaultDeserializationContext ctxt, JsonParser
333314
}
334315

335316
/*
336-
/**********************************************************
317+
/**********************************************************************
337318
/* Life-cycle, fluent factory methods for DeserializationFeatures
338-
/**********************************************************
319+
/**********************************************************************
339320
*/
340321

341322
/**
@@ -390,9 +371,9 @@ public ObjectReader withoutFeatures(DeserializationFeature... features) {
390371
}
391372

392373
/*
393-
/**********************************************************
374+
/**********************************************************************
394375
/* Life-cycle, fluent factory methods for JsonParser.Features
395-
/**********************************************************
376+
/**********************************************************************
396377
*/
397378

398379
/**
@@ -428,9 +409,9 @@ public ObjectReader withoutFeatures(JsonParser.Feature... features) {
428409
}
429410

430411
/*
431-
/**********************************************************
432-
/* Life-cycle, fluent factory methods for FormatFeature (2.7)
433-
/**********************************************************
412+
/**********************************************************************
413+
/* Life-cycle, fluent factory methods for FormatFeature
414+
/**********************************************************************
434415
*/
435416

436417
/**
@@ -466,9 +447,9 @@ public ObjectReader withoutFeatures(FormatFeature... features) {
466447
}
467448

468449
/*
469-
/**********************************************************
450+
/**********************************************************************
470451
/* Life-cycle, fluent factory methods, other
471-
/**********************************************************
452+
/**********************************************************************
472453
*/
473454

474455
/**
@@ -689,9 +670,9 @@ public ObjectReader withoutAttribute(Object key) {
689670
}
690671

691672
/*
692-
/**********************************************************
673+
/**********************************************************************
693674
/* Internal factory methods
694-
/**********************************************************
675+
/**********************************************************************
695676
*/
696677

697678
protected final ObjectReader _with(DeserializationConfig newConfig) {
@@ -700,11 +681,11 @@ protected final ObjectReader _with(DeserializationConfig newConfig) {
700681
}
701682
return _new(this, newConfig);
702683
}
703-
684+
704685
/*
705-
/**********************************************************
686+
/**********************************************************************
706687
/* Simple accessors
707-
/**********************************************************
688+
/**********************************************************************
708689
*/
709690

710691
public boolean isEnabled(DeserializationFeature f) {
@@ -764,10 +745,10 @@ public TypeFactory getTypeFactory() {
764745
}
765746

766747
/*
767-
/**********************************************************
748+
/**********************************************************************
768749
/* Public API: constructing Parsers that are properly linked
769750
/* to `ObjectReadContext`
770-
/**********************************************************
751+
/**********************************************************************
771752
*/
772753

773754
/**
@@ -914,9 +895,9 @@ public JsonParser createNonBlockingByteArrayParser() throws IOException {
914895
}
915896

916897
/*
917-
/**********************************************************
898+
/**********************************************************************
918899
/* Convenience methods for JsonNode creation
919-
/**********************************************************
900+
/**********************************************************************
920901
*/
921902

922903
public ObjectNode createObjectNode() {
@@ -928,10 +909,9 @@ public ArrayNode createArrayNode() {
928909
}
929910

930911
/*
931-
/**********************************************************
932-
/* Deserialization methods; first ones for pre-constructed
933-
/* parsers
934-
/**********************************************************
912+
/**********************************************************************
913+
/* Deserialization methods; first ones for pre-constructed parsers
914+
/**********************************************************************
935915
*/
936916

937917
/**
@@ -1101,9 +1081,9 @@ public <T> Iterator<T> readValues(JsonParser p, JavaType valueType) throws IOExc
11011081
}
11021082

11031083
/*
1104-
/**********************************************************
1084+
/**********************************************************************
11051085
/* TreeCodec impl
1106-
/**********************************************************
1086+
/**********************************************************************
11071087
*/
11081088

11091089
public JsonParser treeAsTokens(TreeNode n) {
@@ -1131,9 +1111,9 @@ public <T extends TreeNode> T readTree(JsonParser p) throws IOException {
11311111
}
11321112

11331113
/*
1134-
/**********************************************************
1114+
/**********************************************************************
11351115
/* Deserialization methods; others similar to what ObjectMapper has
1136-
/**********************************************************
1116+
/**********************************************************************
11371117
*/
11381118

11391119
/**
@@ -1307,9 +1287,9 @@ public JsonNode readTree(DataInput src) throws IOException
13071287
}
13081288

13091289
/*
1310-
/**********************************************************
1290+
/**********************************************************************
13111291
/* Deserialization methods; reading sequence of values
1312-
/**********************************************************
1292+
/**********************************************************************
13131293
*/
13141294

13151295
/**
@@ -1433,9 +1413,9 @@ public <T> MappingIterator<T> readValues(DataInput src) throws IOException
14331413
}
14341414

14351415
/*
1436-
/**********************************************************
1416+
/**********************************************************************
14371417
/* Implementation of rest of ObjectCodec methods
1438-
/**********************************************************
1418+
/**********************************************************************
14391419
*/
14401420

14411421
public <T> T treeToValue(TreeNode n, Class<T> valueType) throws JsonProcessingException
@@ -1450,9 +1430,9 @@ public <T> T treeToValue(TreeNode n, Class<T> valueType) throws JsonProcessingEx
14501430
}
14511431

14521432
/*
1453-
/**********************************************************
1433+
/**********************************************************************
14541434
/* Helper methods, data-binding
1455-
/**********************************************************
1435+
/**********************************************************************
14561436
*/
14571437

14581438
/**
@@ -1644,9 +1624,9 @@ protected final void _verifyNoTrailingTokens(JsonParser p, DeserializationContex
16441624
}
16451625

16461626
/*
1647-
/**********************************************************
1627+
/**********************************************************************
16481628
/* Internal methods, other
1649-
/**********************************************************
1629+
/**********************************************************************
16501630
*/
16511631

16521632
protected void _verifySchemaType(FormatSchema schema)
@@ -1689,9 +1669,9 @@ protected void _reportUndetectableSource(Object src) throws JsonProcessingExcept
16891669
}
16901670

16911671
/*
1692-
/**********************************************************
1672+
/**********************************************************************
16931673
/* Helper methods, locating deserializers etc
1694-
/**********************************************************
1674+
/**********************************************************************
16951675
*/
16961676

16971677
/**

0 commit comments

Comments
 (0)