Skip to content

Commit 63becd4

Browse files
authored
Fix #4818: rename AnnotationIntrospector.findDefaultCreator() as findPreferredCreator (#4819)
1 parent bacc38e commit 63becd4

File tree

6 files changed

+13
-14
lines changed

6 files changed

+13
-14
lines changed

release-notes/VERSION

+1
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ Versions: 3.x (for earlier see VERSION-2.x)
7373
#4659: Remove use of global static `TypeFactory` singleton from 3.0
7474
#4664: Change `EnumNamingStrategy.convertEnumToExternalName()` to take `MapperConfig` argument-
7575
(contributed by Joo-Hyuk K)
76+
#4818: Rename `AnnotationIntrospector.findDefaultCreator()` as `findPreferredCreator()`
7677
- Remove `MappingJsonFactory`
7778
- Add context parameter for `TypeSerializer` contextualization (`forProperty()`)
7879
- Default for `JsonNodeFeature.STRIP_TRAILING_BIGDECIMAL_ZEROES` changed to `false` for 3.0

src/main/java/tools/jackson/databind/AnnotationIntrospector.java

+6-8
Original file line numberDiff line numberDiff line change
@@ -1153,14 +1153,14 @@ public JsonCreator.Mode findCreatorAnnotation(MapperConfig<?> config, Annotated
11531153

11541154
/**
11551155
* Method called to check if introspector can find a Creator it considers
1156-
* the "Primary Creator": Creator to use as the primary one, when no Creator has
1156+
* its "Preferred Creator": Creator to use as the primary one, when no Creator has
11571157
* explicit annotation ({@link #findCreatorAnnotation} returns {@code null}).
1158-
* Examples of default creators include the canonical constructor defined by
1158+
* Examples of preferred creators include the canonical constructor defined by
11591159
* Java Records; "Data" classes by frameworks
11601160
* like Lombok and JVM languages like Kotlin and Scala (case classes) also have
11611161
* similar concepts.
11621162
* If introspector can determine that one of given {@link PotentialCreator}s should
1163-
* be considered the primary, it should return it; if not, should return {@code null}.
1163+
* be considered preferred one, it should return it; if not, it should return {@code null}.
11641164
* Note that core databind functionality may call this method even in the presence of
11651165
* explicitly annotated creators; and may or may not use Creator returned depending
11661166
* on other criteria.
@@ -1171,10 +1171,8 @@ public JsonCreator.Mode findCreatorAnnotation(MapperConfig<?> config, Annotated
11711171
* NOTE: method is NOT called for Java Record types; selection of the canonical constructor
11721172
* as the Primary creator is handled directly by {@link POJOPropertiesCollector}
11731173
*<p>
1174-
* NOTE: naming of this method is unfortunately inconsistent in that "default Creator"
1175-
* has other meanings than "primary Creator" -- in other places Jackson code
1176-
* refers to no-arguments Constructors as "default Creators". So this method
1177-
* ought to have been named {@code findPrimaryCreator()}.
1174+
* NOTE: was called {@code findDefaultCreator()} in Jackson 2.x but was renamed
1175+
* due to possible confusion with 0-argument "default" constructor.
11781176
*
11791177
* @param config Configuration settings in effect (for deserialization)
11801178
* @param valueClass Class being instantiated; defines Creators passed
@@ -1186,7 +1184,7 @@ public JsonCreator.Mode findCreatorAnnotation(MapperConfig<?> config, Annotated
11861184
*
11871185
* @since 2.18
11881186
*/
1189-
public PotentialCreator findDefaultCreator(MapperConfig<?> config,
1187+
public PotentialCreator findPreferredCreator(MapperConfig<?> config,
11901188
AnnotatedClass valueClass,
11911189
List<PotentialCreator> declaredConstructors,
11921190
List<PotentialCreator> declaredFactories) {

src/main/java/tools/jackson/databind/introspect/AnnotationIntrospectorPair.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -665,14 +665,14 @@ public JsonCreator.Mode findCreatorAnnotation(MapperConfig<?> config, Annotated
665665
}
666666

667667
@Override
668-
public PotentialCreator findDefaultCreator(MapperConfig<?> config,
668+
public PotentialCreator findPreferredCreator(MapperConfig<?> config,
669669
AnnotatedClass valueClass,
670670
List<PotentialCreator> declaredConstructors,
671671
List<PotentialCreator> declaredFactories) {
672-
PotentialCreator primaryCtor = _primary.findDefaultCreator(config,
672+
PotentialCreator primaryCtor = _primary.findPreferredCreator(config,
673673
valueClass, declaredConstructors, declaredFactories);
674674
if (primaryCtor == null) {
675-
primaryCtor = _secondary.findDefaultCreator(config,
675+
primaryCtor = _secondary.findPreferredCreator(config,
676676
valueClass, declaredConstructors, declaredFactories);
677677
}
678678
return primaryCtor;

src/main/java/tools/jackson/databind/introspect/POJOPropertiesCollector.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ protected void _addCreators(Map<String, POJOPropertyBuilder> props)
610610
// 02-Nov-2024, tatu: Alas, naming here is confusing: method properly
611611
// should have been "findPrimaryCreator()" so as not to confused with
612612
// 0-args default Creators...
613-
primaryCreator = _annotationIntrospector.findDefaultCreator(_config, _classDef,
613+
primaryCreator = _annotationIntrospector.findPreferredCreator(_config, _classDef,
614614
constructors, factories);
615615
}
616616
// Next: remove creators marked as explicitly disabled

src/test/java/tools/jackson/databind/introspect/DefaultCreatorDetection4584Test.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public PrimaryCreatorFindingIntrospector(JsonCreator.Mode mode,
114114
}
115115

116116
@Override
117-
public PotentialCreator findDefaultCreator(MapperConfig<?> config,
117+
public PotentialCreator findPreferredCreator(MapperConfig<?> config,
118118
AnnotatedClass valueClass,
119119
List<PotentialCreator> declaredConstructors,
120120
List<PotentialCreator> declaredFactories)

src/test/java/tools/jackson/databind/introspect/DefaultCreatorResolution4620Test.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public PrimaryConstructorFindingIntrospector(Class<?>... argTypes) {
4848
}
4949

5050
@Override
51-
public PotentialCreator findDefaultCreator(MapperConfig<?> config,
51+
public PotentialCreator findPreferredCreator(MapperConfig<?> config,
5252
AnnotatedClass valueClass,
5353
List<PotentialCreator> declaredConstructors,
5454
List<PotentialCreator> declaredFactories)

0 commit comments

Comments
 (0)