Skip to content

Commit

Permalink
Continue BasicDeserializerFactory refactoring (#4541)
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder authored May 23, 2024
1 parent 81953a8 commit 590f754
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -247,12 +247,12 @@ protected ValueInstantiator _constructDefaultValueInstantiator(DeserializationCo
BeanDescription beanDesc)
throws JsonMappingException
{
final MapperConfig<?> config = ctxt.getConfig();
final PotentialCreators potentialCreators = beanDesc.getPotentialCreators();
final CreatorCollectionState ccState;
final ConstructorDetector ctorDetector;
final PotentialCreators potentialCreators = beanDesc.getPotentialCreators();

{
final MapperConfig<?> config = ctxt.getConfig();
// need to construct suitable visibility checker:
final VisibilityChecker<?> vchecker = config.getDefaultVisibilityChecker(beanDesc.getBeanClass(),
beanDesc.getClassInfo());
Expand Down Expand Up @@ -292,6 +292,16 @@ protected ValueInstantiator _constructDefaultValueInstantiator(DeserializationCo
if (isNonStaticInnerClass) {
// TODO: look for `@JsonCreator` annotated ones, throw explicit exception?
} else {
// First things first: the "default constructor" (zero-arg
// constructor; whether implicit or explicit) is NOT included
// in list of constructors, so needs to be handled separately.
AnnotatedConstructor defaultCtor = beanDesc.findDefaultConstructor();
if (defaultCtor != null) {
if (!ccState.creators.hasDefaultCreator() || _hasCreatorAnnotation(config, defaultCtor)) {
ccState.creators.setDefaultCreator(defaultCtor);
}
}

// 18-Sep-2020, tatu: Although by default implicit introspection is allowed, 2.12
// has settings to prevent that either generally, or at least for JDK types
final boolean findImplicit = ctorDetector.shouldIntrospectorImplicitConstructors(beanDesc.getBeanClass());
Expand Down Expand Up @@ -354,7 +364,13 @@ public ValueInstantiator _valueInstantiatorInstance(DeserializationConfig config

/*
/**********************************************************************
/* Creator introspection: constructor creator introspection
/* Creator introspection: new (2.18) helper methods
/**********************************************************************
*/

/*
/**********************************************************************
/* OLD Creator introspection: constructor creator introspection
/**********************************************************************
*/

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

// First things first: the "default constructor" (zero-arg
// constructor; whether implicit or explicit) is NOT included
// in list of constructors, so needs to be handled separately.
AnnotatedConstructor defaultCtor = beanDesc.findDefaultConstructor();
if (defaultCtor != null) {
if (!creators.hasDefaultCreator() || _hasCreatorAnnotation(config, defaultCtor)) {
creators.setDefaultCreator(defaultCtor);
}
}
// 21-Sep-2017, tatu: First let's handle explicitly annotated ones
for (AnnotatedConstructor ctor : beanDesc.getConstructors()) {
JsonCreator.Mode creatorMode = intr.findCreatorAnnotation(config, ctor);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,9 @@ protected void _addCreators(Map<String, POJOPropertyBuilder> props)
}
}

// Anything else left, add as possible implicit Creators
creators.setImplicitDelegating(constructors, factories);

// And finally add logical properties for the One Properties-based
// creator selected (if any):
PotentialCreator primary = creators.propertiesBased;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ public class PotentialCreators
private List<PotentialCreator> implicitDelegatingConstructors;
private List<PotentialCreator> implicitDelegatingFactories;

public PotentialCreators()
{
}
public PotentialCreators() { }

/*
/**********************************************************************
Expand Down

0 comments on commit 590f754

Please sign in to comment.