Skip to content

Commit

Permalink
Undo change to eagerly remove disable constructors, factory methods
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Jul 8, 2024
1 parent 279f69c commit d108975
Showing 1 changed file with 18 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ protected void _addCreators(Map<String, POJOPropertyBuilder> props)
final PotentialCreators creators = _potentialCreators;

// First, resolve explicit annotations for all potential Creators
// (note: will skip ones annotated as DISABLED)
// (but do NOT filter out DISABLED ones yet!)
List<PotentialCreator> constructors = _collectCreators(_classDef.getConstructors());
List<PotentialCreator> factories = _collectCreators(_classDef.getFactoryMethods());

Expand All @@ -658,7 +658,10 @@ protected void _addCreators(Map<String, POJOPropertyBuilder> props)
canonical = _annotationIntrospector.findPrimaryCreator(_config, _classDef,
constructors, factories);
}

// Next: remove creators marked as explicitly disabled
_removeDisabledCreators(constructors);
_removeDisabledCreators(factories);

// And then remove non-annotated static methods that do not look like factories
_removeNonFactoryStaticMethods(factories, canonical);

Expand Down Expand Up @@ -759,14 +762,23 @@ private List<PotentialCreator> _collectCreators(List<? extends AnnotatedWithPara
for (AnnotatedWithParams ctor : ctors) {
JsonCreator.Mode creatorMode = _useAnnotations
? _annotationIntrospector.findCreatorAnnotation(_config, ctor) : null;
// 06-Jul-2024, tatu: Let's immediately drop ones marked for ignoral
if (creatorMode != JsonCreator.Mode.DISABLED) {
result.add(new PotentialCreator(ctor, creatorMode));
}
// 06-Jul-2024, tatu: Can't yet drop DISABLED ones; add all (for now)
result.add(new PotentialCreator(ctor, creatorMode));
}
return (result == null) ? Collections.emptyList() : result;
}

private void _removeDisabledCreators(List<PotentialCreator> ctors)
{
Iterator<PotentialCreator> it = ctors.iterator();
while (it.hasNext()) {
// explicitly prevented? Remove
if (it.next().creatorMode() == JsonCreator.Mode.DISABLED) {
it.remove();
}
}
}

private void _removeNonVisibleCreators(List<PotentialCreator> ctors)
{
Iterator<PotentialCreator> it = ctors.iterator();
Expand Down

0 comments on commit d108975

Please sign in to comment.