Skip to content

Commit d9a7f82

Browse files
committed
Prep work for #5175: calc if prop-based Creator has any injectables
1 parent d4f80c6 commit d9a7f82

File tree

4 files changed

+34
-5
lines changed

4 files changed

+34
-5
lines changed

pom.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,9 @@
256256
<excludes>
257257
<exclude>com.fasterxml.jackson.databind.MapperFootprintTest</exclude>
258258
</excludes>
259-
<test>com.fasterxml.jackson.databind.PrimarySuite</test>
259+
<!--
260+
<test>com.fasterxml.jackson.databind.PrimarySuite</test>
261+
-->
260262
<!-- 26-Nov-2019, tatu: moar parallelism! Per-class basis, safe, efficient enough
261263
... although not 100% sure this makes much difference TBH
262264
-->

src/main/java/com/fasterxml/jackson/databind/deser/CreatorProperty.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,11 @@ public Object getInjectableValueId() {
280280
return (_injectableValue == null) ? null : _injectableValue.getId();
281281
}
282282

283+
@Override // since 2.21
284+
public JacksonInject.Value getInjectionDefinition() {
285+
return _injectableValue;
286+
}
287+
283288
@Override
284289
public boolean isInjectionOnly() {
285290
return (_injectableValue != null) && !_injectableValue.willUseInput(true);

src/main/java/com/fasterxml/jackson/databind/deser/SettableBeanProperty.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import java.io.IOException;
44
import java.lang.annotation.Annotation;
55

6+
import com.fasterxml.jackson.annotation.JacksonInject;
67
import com.fasterxml.jackson.core.*;
78
import com.fasterxml.jackson.databind.*;
89
import com.fasterxml.jackson.databind.deser.impl.FailingDeserializer;
@@ -468,6 +469,14 @@ public int getCreatorIndex() {
468469
*/
469470
public Object getInjectableValueId() { return null; }
470471

472+
/**
473+
* Accessor for injection definition, if this bean property supports
474+
* value injection.
475+
*
476+
* @since 2.21
477+
*/
478+
public JacksonInject.Value getInjectionDefinition() { return null; }
479+
471480
/**
472481
* Accessor for checking whether this property is injectable, and if so,
473482
* ONLY injectable (will not bind from input).

src/main/java/com/fasterxml/jackson/databind/deser/impl/PropertyBasedCreator.java

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,14 @@ public final class PropertyBasedCreator
4545
*/
4646
protected final SettableBeanProperty[] _allProperties;
4747

48+
/**
49+
* Marker that indicates whether any of the creator properties has
50+
* associated injectable value to be injected.
51+
*
52+
* @since 2.21
53+
*/
54+
protected final boolean _hasInjectables;
55+
4856
/*
4957
/**********************************************************
5058
/* Construction, initialization
@@ -61,11 +69,8 @@ protected PropertyBasedCreator(DeserializationContext ctxt,
6169
if (caseInsensitive) {
6270
_propertyLookup = CaseInsensitiveMap.construct(ctxt.getConfig().getLocale());
6371
} else {
64-
_propertyLookup = new HashMap<String, SettableBeanProperty>();
72+
_propertyLookup = new HashMap<>();
6573
}
66-
final int len = creatorProps.length;
67-
_propertyCount = len;
68-
_allProperties = new SettableBeanProperty[len];
6974

7075
// 26-Feb-2017, tatu: Let's start by aliases, so that there is no
7176
// possibility of accidental override of primary names
@@ -83,14 +88,21 @@ protected PropertyBasedCreator(DeserializationContext ctxt,
8388
}
8489
}
8590
}
91+
final int len = creatorProps.length;
92+
_propertyCount = len;
93+
_allProperties = new SettableBeanProperty[len];
94+
boolean injectables = false;
8695
for (int i = 0; i < len; ++i) {
8796
SettableBeanProperty prop = creatorProps[i];
8897
_allProperties[i] = prop;
8998
// 22-Jan-2018, tatu: ignorable entries should be skipped
9099
if (!prop.isIgnorable()) {
91100
_propertyLookup.put(prop.getName(), prop);
92101
}
102+
injectables |= prop.getInjectionDefinition() != null;
93103
}
104+
105+
_hasInjectables = injectables;
94106
}
95107

96108
/**
@@ -102,6 +114,7 @@ protected PropertyBasedCreator(PropertyBasedCreator base,
102114
{
103115
_propertyCount = base._propertyCount;
104116
_valueInstantiator = base._valueInstantiator;
117+
_hasInjectables = base._hasInjectables;
105118
_propertyLookup = propertyLookup;
106119
_allProperties = allProperties;
107120
}

0 commit comments

Comments
 (0)