Skip to content

Commit 721e159

Browse files
committed
Post-merge clean up for #4615 (#4584)
1 parent 2d7c850 commit 721e159

File tree

4 files changed

+21
-17
lines changed

4 files changed

+21
-17
lines changed

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

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1398,14 +1398,18 @@ public JsonCreator.Mode findCreatorAnnotation(MapperConfig<?> config, Annotated
13981398
}
13991399

14001400
/**
1401-
* Method called to check if introspector is able to detect so-called Primary
1402-
* Creator: Creator to select for use when no explicit annotation is found
1403-
* (via {@link #findCreatorAnnotation}).
1404-
* This is the case for example for Java Record types which have so-called
1405-
* canonical constructor; but it is also true for various "Data" classes by frameworks
1406-
* like Lombok and JVM languages like Kotlin and Scala (case classes).
1401+
* Method called to check if introspector can find a Creator it considers
1402+
* the "Default Creator": Creator to use as the primary, when no Creator has
1403+
* explicit annotation ({@link #findCreatorAnnotation} returns {@code null}).
1404+
* Examples of default creators include the canonical constructor defined by
1405+
* Java Records; "Data" classes by frameworks
1406+
* like Lombok and JVM languages like Kotlin and Scala (case classes) also have
1407+
* similar concepts.
14071408
* If introspector can determine that one of given {@link PotentialCreator}s should
1408-
* be considered Primary, it should return it; if not, should return {@code null}.
1409+
* be considered the default, it should return it; if not, should return {@code null}.
1410+
* Note that core databind functionality may call this method even in the presence of
1411+
* explicitly annotated creators; and may or may not use Creator returned depending
1412+
* on other criteria.
14091413
*<p>
14101414
* NOTE: when returning chosen Creator, it may be necessary to mark its "mode"
14111415
* with {@link PotentialCreator#overrideMode} (especially for "delegating" creators).
@@ -1414,16 +1418,16 @@ public JsonCreator.Mode findCreatorAnnotation(MapperConfig<?> config, Annotated
14141418
* as the Primary creator is handled directly by {@link POJOPropertiesCollector}
14151419
*
14161420
* @param config Configuration settings in effect (for deserialization)
1417-
* @param valueClass Class being instantiated and defines Creators passed
1421+
* @param valueClass Class being instantiated; defines Creators passed
14181422
* @param declaredConstructors Constructors value class declares
14191423
* @param declaredFactories Factory methods value class declares
14201424
*
1421-
* @return The one Canonical Creator to use for {@code valueClass}, if it can be
1425+
* @return Default Creator to possibly use for {@code valueClass}, if one can be
14221426
* determined; {@code null} if not.
14231427
*
14241428
* @since 2.18
14251429
*/
1426-
public PotentialCreator findPrimaryCreator(MapperConfig<?> config,
1430+
public PotentialCreator findDefaultCreator(MapperConfig<?> config,
14271431
AnnotatedClass valueClass,
14281432
List<PotentialCreator> declaredConstructors,
14291433
List<PotentialCreator> declaredFactories) {

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -736,17 +736,17 @@ public JsonCreator.Mode findCreatorAnnotation(MapperConfig<?> config, Annotated
736736
}
737737

738738
@Override
739-
public PotentialCreator findPrimaryCreator(MapperConfig<?> config,
739+
public PotentialCreator findDefaultCreator(MapperConfig<?> config,
740740
AnnotatedClass valueClass,
741741
List<PotentialCreator> declaredConstructors,
742742
List<PotentialCreator> declaredFactories) {
743-
PotentialCreator primary = _primary.findPrimaryCreator(config,
743+
PotentialCreator defCtor = _primary.findDefaultCreator(config,
744744
valueClass, declaredConstructors, declaredFactories);
745-
if (primary == null) {
746-
primary = _secondary.findPrimaryCreator(config,
745+
if (defCtor == null) {
746+
defCtor = _secondary.findDefaultCreator(config,
747747
valueClass, declaredConstructors, declaredFactories);
748748
}
749-
return primary;
749+
return defCtor;
750750
}
751751

752752
/*

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,7 @@ protected void _addCreators(Map<String, POJOPropertyBuilder> props)
655655
if (_isRecordType) {
656656
primary = JDK14Util.findCanonicalRecordConstructor(_config, _classDef, constructors);
657657
} else {
658-
primary = _annotationIntrospector.findPrimaryCreator(_config, _classDef,
658+
primary = _annotationIntrospector.findDefaultCreator(_config, _classDef,
659659
constructors, factories);
660660
}
661661
// Next: remove creators marked as explicitly disabled

src/test/java/com/fasterxml/jackson/databind/introspect/PrimaryCreatorDetection4584Test.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public PrimaryCreatorFindingIntrospector(JsonCreator.Mode mode,
113113
}
114114

115115
@Override
116-
public PotentialCreator findPrimaryCreator(MapperConfig<?> config,
116+
public PotentialCreator findDefaultCreator(MapperConfig<?> config,
117117
AnnotatedClass valueClass,
118118
List<PotentialCreator> declaredConstructors,
119119
List<PotentialCreator> declaredFactories)

0 commit comments

Comments
 (0)