Skip to content

Commit a769351

Browse files
committed
Last part of this round of refactoring aimed at passing full PropertyName (not just simple name) via POJO properties collector
1 parent 916ee4d commit a769351

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

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

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -435,14 +435,13 @@ protected void _addCreators()
435435
for (int i = 0, len = ctor.getParameterCount(); i < len; ++i) {
436436
AnnotatedParameter param = ctor.getParameter(i);
437437
PropertyName pn = ai.findNameForDeserialization(param);
438-
String name = (pn == null) ? null : pn.getSimpleName();
439438
// is it legal not to have name?
440-
if (name != null && name.length() > 0) {
439+
if (pn != null && !pn.isEmpty()) {
441440
// shouldn't need to worry about @JsonIgnore (no real point, so)
442-
POJOPropertyBuilder prop = _property(name);
441+
POJOPropertyBuilder prop = _property(pn);
443442
// 28-Mar-2014, tatu: for now, all creator names considered explicit;
444443
// may need to change for JDK 8 where implicit names exist
445-
prop.addCtor(param, name, true, true, false);
444+
prop.addCtor(param, pn, true, true, false);
446445
_creatorProperties.add(prop);
447446
}
448447
}
@@ -454,13 +453,12 @@ protected void _addCreators()
454453
for (int i = 0, len = factory.getParameterCount(); i < len; ++i) {
455454
AnnotatedParameter param = factory.getParameter(i);
456455
PropertyName pn = ai.findNameForDeserialization(param);
457-
String name = (pn == null) ? null : pn.getSimpleName();
458456
// is it legal not to have name?
459-
if (name != null) {
457+
if (pn != null && !pn.isEmpty()) {
460458
// shouldn't need to worry about @JsonIgnore (no real point, so)
461-
POJOPropertyBuilder prop = _property(name);
459+
POJOPropertyBuilder prop = _property(pn);
462460
// 28-Mar-2014, tatu: for now, all names considered explicit
463-
prop.addCtor(param, name, true, true, false);
461+
prop.addCtor(param, pn, true, true, false);
464462
_creatorProperties.add(prop);
465463
}
466464
}
@@ -824,7 +822,12 @@ protected void _renameWithWrappers()
824822
protected void reportProblem(String msg) {
825823
throw new IllegalArgumentException("Problem with definition of "+_classDef+": "+msg);
826824
}
825+
826+
protected POJOPropertyBuilder _property(PropertyName name) {
827+
return _property(name.getSimpleName());
828+
}
827829

830+
// !!! TODO: deprecate, require use of PropertyName
828831
protected POJOPropertyBuilder _property(String implName)
829832
{
830833
POJOPropertyBuilder prop = _properties.get(implName);

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -778,10 +778,6 @@ private Linked<? extends AnnotatedMember> findRenamed(Linked<? extends Annotated
778778
}
779779
PropertyName name = node.name;
780780
// different from default name?
781-
/* 14-Mar-2014, tatu: As per [#369], Must match local name... but,
782-
* shouldn't really exclude namespace. Not sure what's the best
783-
* fix but for now, let's not worry about that.
784-
*/
785781
if (name.equals(_name)) { // nope, skip
786782
continue;
787783
}
@@ -878,6 +874,10 @@ public Linked(T v, Linked<T> n,
878874
next = n;
879875
// ensure that we'll never have missing names
880876
this.name = (name == null || !name.hasSimpleName()) ? null : name;
877+
878+
if (explName && this.name == null) { // sanity check to catch internal problems
879+
throw new IllegalArgumentException("Can not pass true for 'explName' if name is null/empty");
880+
}
881881

882882
isNameExplicit = explName;
883883
isVisible = visible;

0 commit comments

Comments
 (0)