@@ -41,6 +41,12 @@ public class POJOPropertiesCollector
41
41
*/
42
42
protected final boolean _forSerialization ;
43
43
44
+ /**
45
+ * @since 2.5
46
+ */
47
+ @ Deprecated
48
+ protected final boolean _stdBeanNaming ;
49
+
44
50
/**
45
51
* Type of POJO for which properties are being collected.
46
52
*/
@@ -60,6 +66,13 @@ public class POJOPropertiesCollector
60
66
*/
61
67
protected final boolean _useAnnotations ;
62
68
69
+ /**
70
+ * Prefix used by auto-detected mutators ("setters"): usually "set",
71
+ * but differs for builder objects ("with" by default).
72
+ */
73
+ @ Deprecated
74
+ protected final String _mutatorPrefix ;
75
+
63
76
/*
64
77
/**********************************************************
65
78
/* Collected property information
@@ -144,13 +157,28 @@ public class POJOPropertiesCollector
144
157
/**********************************************************
145
158
*/
146
159
160
+ @ Deprecated
161
+ protected POJOPropertiesCollector (MapperConfig <?> config , boolean forSerialization ,
162
+ JavaType type , AnnotatedClass classDef , String mutatorPrefix )
163
+ {
164
+ this (config , forSerialization , type , classDef , null , mutatorPrefix );
165
+ }
166
+
147
167
protected POJOPropertiesCollector (MapperConfig <?> config , boolean forSerialization ,
148
168
JavaType type , AnnotatedClass classDef , AccessorNamingStrategy accessorNaming )
169
+ {
170
+ this (config , forSerialization , type , classDef , accessorNaming , null );
171
+ }
172
+
173
+ private POJOPropertiesCollector (MapperConfig <?> config , boolean forSerialization ,
174
+ JavaType type , AnnotatedClass classDef , AccessorNamingStrategy accessorNaming , String mutatorPrefix )
149
175
{
150
176
_config = config ;
177
+ _stdBeanNaming = config .isEnabled (MapperFeature .USE_STD_BEAN_NAMING );
151
178
_forSerialization = forSerialization ;
152
179
_type = type ;
153
180
_classDef = classDef ;
181
+ _mutatorPrefix = (mutatorPrefix == null ) ? "set" : mutatorPrefix ;
154
182
if (config .isAnnotationProcessingEnabled ()) {
155
183
_useAnnotations = true ;
156
184
_annotationIntrospector = _config .getAnnotationIntrospector ();
@@ -160,7 +188,8 @@ protected POJOPropertiesCollector(MapperConfig<?> config, boolean forSerializati
160
188
}
161
189
_visibilityChecker = _config .getDefaultVisibilityChecker (type .getRawClass (),
162
190
classDef );
163
- _accessorNaming = accessorNaming ;
191
+ _accessorNaming = (null != accessorNaming ) ? accessorNaming :
192
+ new DefaultAccessorNamingStrategy .Provider ().withSetterPrefix (mutatorPrefix ).forPOJO (config , classDef );
164
193
}
165
194
166
195
/*
@@ -964,7 +993,9 @@ protected void _renameProperties(Map<String, POJOPropertyBuilder> props)
964
993
old .addAll (prop );
965
994
}
966
995
// replace the creatorProperty too, if there is one
967
- if (_updateCreatorProperty (prop , _creatorProperties )) {
996
+ MonitoredList <POJOPropertyBuilder > monitored = MonitoredList .monitor (_creatorProperties );
997
+ _updateCreatorProperty (prop , monitored );
998
+ if (null != monitored && monitored .isModified ()) {
968
999
// [databind#2001]: New name of property was ignored previously? Remove from ignored
969
1000
// 01-May-2018, tatu: I have a feeling this will need to be revisited at some point,
970
1001
// to avoid removing some types of removals, possibly. But will do for now.
@@ -1276,17 +1307,59 @@ private PropertyNamingStrategy _findNamingStrategy()
1276
1307
_config .canOverrideAccessModifiers ());
1277
1308
}
1278
1309
1279
- protected boolean _updateCreatorProperty (POJOPropertyBuilder prop , List <POJOPropertyBuilder > creatorProperties ) {
1310
+ protected void _updateCreatorProperty (POJOPropertyBuilder prop , List <POJOPropertyBuilder > creatorProperties ) {
1280
1311
1281
1312
if (creatorProperties != null ) {
1282
1313
final String intName = prop .getInternalName ();
1283
1314
for (int i = 0 , len = creatorProperties .size (); i < len ; ++i ) {
1284
1315
if (creatorProperties .get (i ).getInternalName ().equals (intName )) {
1285
1316
creatorProperties .set (i , prop );
1286
- return true ;
1317
+ break ;
1287
1318
}
1288
1319
}
1289
1320
}
1290
- return false ;
1321
+ }
1322
+
1323
+ private static class MonitoredList <T > extends AbstractList <T > {
1324
+ private final List <T > delegate ;
1325
+ private boolean modified ;
1326
+
1327
+ public MonitoredList (List <T > delegate ) {
1328
+ this .delegate = delegate ;
1329
+ this .modified = false ;
1330
+ }
1331
+
1332
+ @ Override
1333
+ public T get (int index ) {
1334
+ return this .delegate .get (index );
1335
+ }
1336
+
1337
+ @ Override
1338
+ public int size () {
1339
+ return this .delegate .size ();
1340
+ }
1341
+
1342
+ public T set (int index , T element ) {
1343
+ this .modified = true ;
1344
+ return this .delegate .set (index , element );
1345
+ }
1346
+
1347
+ public void add (int index , T element ) {
1348
+ this .modified = true ;
1349
+ this .delegate .add (index , element );
1350
+ }
1351
+
1352
+ public T remove (int index ) {
1353
+ this .modified = true ;
1354
+ return this .delegate .remove (index );
1355
+ }
1356
+
1357
+ public boolean isModified () {
1358
+ return this .modified ;
1359
+ }
1360
+
1361
+ public static <T > MonitoredList <T > monitor (List <T > source ) {
1362
+ return null == source ? null : new MonitoredList <>(source );
1363
+ }
1291
1364
}
1292
1365
}
0 commit comments