Skip to content

Commit 590f754

Browse files
authored
Continue BasicDeserializerFactory refactoring (#4541)
1 parent 81953a8 commit 590f754

File tree

3 files changed

+23
-15
lines changed

3 files changed

+23
-15
lines changed

src/main/java/com/fasterxml/jackson/databind/deser/BasicDeserializerFactory.java

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -247,12 +247,12 @@ protected ValueInstantiator _constructDefaultValueInstantiator(DeserializationCo
247247
BeanDescription beanDesc)
248248
throws JsonMappingException
249249
{
250+
final MapperConfig<?> config = ctxt.getConfig();
251+
final PotentialCreators potentialCreators = beanDesc.getPotentialCreators();
250252
final CreatorCollectionState ccState;
251253
final ConstructorDetector ctorDetector;
252-
final PotentialCreators potentialCreators = beanDesc.getPotentialCreators();
253254

254255
{
255-
final MapperConfig<?> config = ctxt.getConfig();
256256
// need to construct suitable visibility checker:
257257
final VisibilityChecker<?> vchecker = config.getDefaultVisibilityChecker(beanDesc.getBeanClass(),
258258
beanDesc.getClassInfo());
@@ -292,6 +292,16 @@ protected ValueInstantiator _constructDefaultValueInstantiator(DeserializationCo
292292
if (isNonStaticInnerClass) {
293293
// TODO: look for `@JsonCreator` annotated ones, throw explicit exception?
294294
} else {
295+
// First things first: the "default constructor" (zero-arg
296+
// constructor; whether implicit or explicit) is NOT included
297+
// in list of constructors, so needs to be handled separately.
298+
AnnotatedConstructor defaultCtor = beanDesc.findDefaultConstructor();
299+
if (defaultCtor != null) {
300+
if (!ccState.creators.hasDefaultCreator() || _hasCreatorAnnotation(config, defaultCtor)) {
301+
ccState.creators.setDefaultCreator(defaultCtor);
302+
}
303+
}
304+
295305
// 18-Sep-2020, tatu: Although by default implicit introspection is allowed, 2.12
296306
// has settings to prevent that either generally, or at least for JDK types
297307
final boolean findImplicit = ctorDetector.shouldIntrospectorImplicitConstructors(beanDesc.getBeanClass());
@@ -354,7 +364,13 @@ public ValueInstantiator _valueInstantiatorInstance(DeserializationConfig config
354364

355365
/*
356366
/**********************************************************************
357-
/* Creator introspection: constructor creator introspection
367+
/* Creator introspection: new (2.18) helper methods
368+
/**********************************************************************
369+
*/
370+
371+
/*
372+
/**********************************************************************
373+
/* OLD Creator introspection: constructor creator introspection
358374
/**********************************************************************
359375
*/
360376

@@ -369,15 +385,6 @@ protected void _addExplicitConstructorCreators(DeserializationContext ctxt,
369385
final VisibilityChecker<?> vchecker = ccState.vchecker;
370386
final Map<AnnotatedWithParams, BeanPropertyDefinition[]> creatorParams = ccState.creatorParams;
371387

372-
// First things first: the "default constructor" (zero-arg
373-
// constructor; whether implicit or explicit) is NOT included
374-
// in list of constructors, so needs to be handled separately.
375-
AnnotatedConstructor defaultCtor = beanDesc.findDefaultConstructor();
376-
if (defaultCtor != null) {
377-
if (!creators.hasDefaultCreator() || _hasCreatorAnnotation(config, defaultCtor)) {
378-
creators.setDefaultCreator(defaultCtor);
379-
}
380-
}
381388
// 21-Sep-2017, tatu: First let's handle explicitly annotated ones
382389
for (AnnotatedConstructor ctor : beanDesc.getConstructors()) {
383390
JsonCreator.Mode creatorMode = intr.findCreatorAnnotation(config, ctor);

src/main/java/com/fasterxml/jackson/databind/introspect/POJOPropertiesCollector.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -689,6 +689,9 @@ protected void _addCreators(Map<String, POJOPropertyBuilder> props)
689689
}
690690
}
691691

692+
// Anything else left, add as possible implicit Creators
693+
creators.setImplicitDelegating(constructors, factories);
694+
692695
// And finally add logical properties for the One Properties-based
693696
// creator selected (if any):
694697
PotentialCreator primary = creators.propertiesBased;

src/main/java/com/fasterxml/jackson/databind/introspect/PotentialCreators.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ public class PotentialCreators
1616
private List<PotentialCreator> implicitDelegatingConstructors;
1717
private List<PotentialCreator> implicitDelegatingFactories;
1818

19-
public PotentialCreators()
20-
{
21-
}
19+
public PotentialCreators() { }
2220

2321
/*
2422
/**********************************************************************

0 commit comments

Comments
 (0)