Skip to content

Commit 682eef5

Browse files
committed
Minor fixing; make creatorMode nullable again
1 parent 47c04b3 commit 682eef5

File tree

2 files changed

+21
-9
lines changed

2 files changed

+21
-9
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -734,13 +734,13 @@ protected void _addCreators(Map<String, POJOPropertyBuilder> props)
734734
private boolean _isDelegatingConstructor(PotentialCreator ctor)
735735
{
736736
// First things first: could be
737-
switch (ctor.creatorMode()) {
737+
switch (ctor.creatorModeOrDefault()) {
738738
case DELEGATING:
739739
return true;
740740
case DISABLED:
741741
case PROPERTIES:
742742
return false;
743-
default:
743+
default: // case DEFAULT:
744744
}
745745

746746
// Only consider single-arg case, for now
@@ -797,7 +797,7 @@ private void _removeNonFactoryStaticMethods(List<PotentialCreator> ctors,
797797
while (it.hasNext()) {
798798
// explicit mode? Retain (for now)
799799
PotentialCreator ctor = it.next();
800-
if (ctor.creatorMode() != null) {
800+
if (ctor.creatorMode() != JsonCreator.Mode.DEFAULT) {
801801
continue;
802802
}
803803
// Do not trim canonical either

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

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ public class PotentialCreator
1919

2020
private final AnnotatedWithParams creator;
2121

22+
/**
23+
* Declared Mode of the creator, if explicitly annotated; {@code null} otherwise
24+
*/
2225
private JsonCreator.Mode creatorMode;
2326

2427
private PropertyName[] implicitParamNames;
@@ -35,9 +38,6 @@ public PotentialCreator(AnnotatedWithParams cr,
3538
JsonCreator.Mode cm)
3639
{
3740
creator = cr;
38-
if (cm == null) {
39-
cm = JsonCreator.Mode.DEFAULT;
40-
}
4141
creatorMode = cm;
4242
}
4343

@@ -51,9 +51,6 @@ public PotentialCreator(AnnotatedWithParams cr,
5151
* @return This creator instance
5252
*/
5353
public PotentialCreator overrideMode(JsonCreator.Mode mode) {
54-
if (mode == null) {
55-
mode = JsonCreator.Mode.DEFAULT;
56-
}
5754
creatorMode = mode;
5855
return this;
5956
}
@@ -141,10 +138,25 @@ public AnnotatedWithParams creator() {
141138
return creator;
142139
}
143140

141+
/**
142+
* @return Mode declared for this Creator by annotation, if any; {@code null}
143+
* if not annotated
144+
*/
144145
public JsonCreator.Mode creatorMode() {
145146
return creatorMode;
146147
}
147148

149+
/**
150+
* Same as {@link #creatorMode()} except that if {@code null} was to be
151+
* returned, will instead return {@code JsonCreator.Mode.DEFAULT}/
152+
*/
153+
public JsonCreator.Mode creatorModeOrDefault() {
154+
if (creatorMode == null) {
155+
return JsonCreator.Mode.DEFAULT;
156+
}
157+
return creatorMode;
158+
}
159+
148160
public int paramCount() {
149161
return creator.getParameterCount();
150162
}

0 commit comments

Comments
 (0)