21
21
public class POJOPropertiesCollector
22
22
{
23
23
/*
24
- /**********************************************************
24
+ /**********************************************************************
25
25
/* Configuration
26
- /**********************************************************
26
+ /**********************************************************************
27
27
*/
28
28
29
29
/**
@@ -58,11 +58,11 @@ public class POJOPropertiesCollector
58
58
* but differs for builder objects ("with" by default).
59
59
*/
60
60
protected final String _mutatorPrefix ;
61
-
61
+
62
62
/*
63
- /**********************************************************
63
+ /**********************************************************************
64
64
/* Collected property information
65
- /**********************************************************
65
+ /**********************************************************************
66
66
*/
67
67
68
68
/**
@@ -106,11 +106,11 @@ public class POJOPropertiesCollector
106
106
* value injection.
107
107
*/
108
108
protected LinkedHashMap <Object , AnnotatedMember > _injectables ;
109
-
109
+
110
110
/*
111
- /**********************************************************
111
+ /**********************************************************************
112
112
/* Life-cycle
113
- /**********************************************************
113
+ /**********************************************************************
114
114
*/
115
115
116
116
protected POJOPropertiesCollector (MapperConfig <?> config , boolean forSerialization ,
@@ -133,9 +133,9 @@ protected POJOPropertiesCollector(MapperConfig<?> config, boolean forSerializati
133
133
}
134
134
135
135
/*
136
- /**********************************************************
136
+ /**********************************************************************
137
137
/* Public API
138
- /**********************************************************
138
+ /**********************************************************************
139
139
*/
140
140
141
141
public MapperConfig <?> getConfig () {
@@ -267,9 +267,9 @@ protected Map<String, POJOPropertyBuilder> getPropertyMap() {
267
267
}
268
268
269
269
/*
270
- /**********************************************************
270
+ /**********************************************************************
271
271
/* Public API: main-level collection
272
- /**********************************************************
272
+ /**********************************************************************
273
273
*/
274
274
275
275
/**
@@ -289,6 +289,9 @@ protected void collectAll()
289
289
}
290
290
_addInjectables (props );
291
291
292
+ // 27-Dec-2019, tatu: [databind#2527] initial re-linking by Field needs to
293
+ // be applied before other processing
294
+
292
295
// Remove ignored properties, first; this MUST precede annotation merging
293
296
// since logic relies on knowing exactly which accessor has which annotation
294
297
_removeUnwantedProperties (props );
@@ -326,9 +329,9 @@ protected void collectAll()
326
329
}
327
330
328
331
/*
329
- /**********************************************************
332
+ /**********************************************************************
330
333
/* Overridable internal methods, adding members
331
- /**********************************************************
334
+ /**********************************************************************
332
335
*/
333
336
334
337
/**
@@ -343,7 +346,7 @@ protected void _addFields(Map<String, POJOPropertyBuilder> props)
343
346
*/
344
347
final boolean pruneFinalFields = !_forSerialization && !_config .isEnabled (MapperFeature .ALLOW_FINAL_FIELDS_AS_MUTATORS );
345
348
final boolean transientAsIgnoral = _config .isEnabled (MapperFeature .PROPAGATE_TRANSIENT_MARKER );
346
-
349
+
347
350
for (AnnotatedField f : _classDef .fields ()) {
348
351
// @JsonValue?
349
352
if (Boolean .TRUE .equals (ai .hasAsValue (_config , f ))) {
@@ -356,7 +359,7 @@ protected void _addFields(Map<String, POJOPropertyBuilder> props)
356
359
// @JsonAnySetter?
357
360
if (Boolean .TRUE .equals (ai .hasAnySetter (_config , f ))) {
358
361
if (_anySetterField == null ) {
359
- _anySetterField = new LinkedList <AnnotatedMember >();
362
+ _anySetterField = new LinkedList <>();
360
363
}
361
364
_anySetterField .add (f );
362
365
continue ;
@@ -365,14 +368,22 @@ protected void _addFields(Map<String, POJOPropertyBuilder> props)
365
368
if (implName == null ) {
366
369
implName = f .getName ();
367
370
}
371
+
372
+ // [databind#2527: Field-based renaming can be applied early (here),
373
+ // or at a later point, but probably must be done before pruning
374
+ // final fields. So let's do it early here
375
+ final PropertyName rename = ai .findRenameByField (_config , f , _propNameFromSimple (implName ));
376
+ if (rename != null ) {
377
+ // todo
378
+ }
379
+
368
380
PropertyName pn ;
369
381
370
382
if (_forSerialization ) {
371
- /* 18-Aug-2011, tatu: As per existing unit tests, we should only
372
- * use serialization annotation (@JsonSerialize) when serializing
373
- * fields, and similarly for deserialize-only annotations... so
374
- * no fallbacks in this particular case.
375
- */
383
+ // 18-Aug-2011, tatu: As per existing unit tests, we should only
384
+ // use serialization annotation (@JsonSerialize) when serializing
385
+ // fields, and similarly for deserialize-only annotations... so
386
+ // no fallbacks in this particular case.
376
387
pn = ai .findNameForSerialization (_config , f );
377
388
} else {
378
389
pn = ai .findNameForDeserialization (_config , f );
@@ -405,7 +416,7 @@ protected void _addFields(Map<String, POJOPropertyBuilder> props)
405
416
}
406
417
/* [databind#190]: this is the place to prune final fields, if they are not
407
418
* to be used as mutators. Must verify they are not explicitly included.
408
- * Also: if 'ignored' is set, need to included until a later point, to
419
+ * Also: if 'ignored' is set, need to include until a later point, to
409
420
* avoid losing ignoral information.
410
421
*/
411
422
if (pruneFinalFields && (pn == null ) && !ignored
@@ -427,15 +438,15 @@ protected void _addCreators(Map<String, POJOPropertyBuilder> props)
427
438
}
428
439
for (AnnotatedConstructor ctor : _classDef .getConstructors ()) {
429
440
if (_creatorProperties == null ) {
430
- _creatorProperties = new LinkedList <POJOPropertyBuilder >();
441
+ _creatorProperties = new LinkedList <>();
431
442
}
432
443
for (int i = 0 , len = ctor .getParameterCount (); i < len ; ++i ) {
433
444
_addCreatorParam (props , ctor .getParameter (i ));
434
445
}
435
446
}
436
447
for (AnnotatedMethod factory : _classDef .getFactoryMethods ()) {
437
448
if (_creatorProperties == null ) {
438
- _creatorProperties = new LinkedList <POJOPropertyBuilder >();
449
+ _creatorProperties = new LinkedList <>();
439
450
}
440
451
for (int i = 0 , len = factory .getParameterCount (); i < len ; ++i ) {
441
452
_addCreatorParam (props , factory .getParameter (i ));
@@ -654,11 +665,11 @@ protected void _doAddInjectable(JacksonInject.Value injectable, AnnotatedMember
654
665
private PropertyName _propNameFromSimple (String simpleName ) {
655
666
return PropertyName .construct (simpleName , null );
656
667
}
657
-
668
+
658
669
/*
659
- /**********************************************************
670
+ /**********************************************************************
660
671
/* Internal methods; removing ignored properties
661
- /**********************************************************
672
+ /**********************************************************************
662
673
*/
663
674
664
675
/**
@@ -729,9 +740,9 @@ private void _collectIgnorals(String name)
729
740
}
730
741
731
742
/*
732
- /**********************************************************
743
+ /**********************************************************************
733
744
/* Internal methods; renaming properties
734
- /**********************************************************
745
+ /**********************************************************************
735
746
*/
736
747
737
748
protected void _renameProperties (Map <String , POJOPropertyBuilder > props )
@@ -893,9 +904,9 @@ protected void _renameWithWrappers(Map<String, POJOPropertyBuilder> props)
893
904
}
894
905
895
906
/*
896
- /**********************************************************
907
+ /**********************************************************************
897
908
/* Overridable internal methods, sorting, other stuff
898
- /**********************************************************
909
+ /**********************************************************************
899
910
*/
900
911
901
912
// First, order by(explicit ordering and/or alphabetic),
@@ -1014,9 +1025,9 @@ private boolean _anyIndexed(Collection<POJOPropertyBuilder> props) {
1014
1025
}
1015
1026
1016
1027
/*
1017
- /**********************************************************
1028
+ /**********************************************************************
1018
1029
/* Internal methods; helpers
1019
- /**********************************************************
1030
+ /**********************************************************************
1020
1031
*/
1021
1032
1022
1033
protected void reportProblem (String msg , Object ... args ) {
0 commit comments