@@ -47,10 +47,6 @@ public class PodamFactoryImpl implements PodamFactory {
47
47
/** Application logger */
48
48
private static final Logger LOG = LoggerFactory .getLogger (PodamFactoryImpl .class );
49
49
50
- /** Empty type map */
51
- private static final Map <String , Type > NULL_TYPE_ARGS_MAP = new HashMap <String , Type >();
52
-
53
-
54
50
// ------------------->> Instance / variables
55
51
56
52
/**
@@ -480,8 +476,7 @@ private <T> T manufacturePojoInternal(Class<T> pojoClass,
480
476
pojoClass , Arrays .toString (genericTypeArgs ));
481
477
}
482
478
483
- Map <String , Type > typeArgsMap = manufacturingCtx .getTypeArgsMap ();
484
- manufacturingCtx .setTypeArgsMap (new HashMap <String , Type >());
479
+ manufacturingCtx .backupTypeArgsMap (manufacturingCtx .createEmptyTypeArgsMap ());
485
480
Type [] genericTypeArgsExtra = TypeManufacturerUtil .fillTypeArgMap (
486
481
manufacturingCtx .getTypeArgsMap (), pojoClass , genericTypeArgs );
487
482
@@ -514,7 +509,7 @@ private <T> T manufacturePojoInternal(Class<T> pojoClass,
514
509
genericTypeArgsExtra );
515
510
}
516
511
517
- manufacturingCtx .setTypeArgsMap ( typeArgsMap );
512
+ manufacturingCtx .restoreTypeArgsMap ( );
518
513
return retValue ;
519
514
}
520
515
@@ -705,13 +700,12 @@ private <T> boolean populateReadOnlyField(T pojo, ClassAttribute attribute,
705
700
}
706
701
if (depth < strategy .getMaxDepth (fieldClass )) {
707
702
708
- Map <String , Type > typeArgsMap = manufacturingCtx .getTypeArgsMap ();
709
- manufacturingCtx .setTypeArgsMap (paramTypeArgsMap );
703
+ manufacturingCtx .backupTypeArgsMap (paramTypeArgsMap );
710
704
manufacturingCtx .getPojos ().put (fieldClass , depth + 1 );
711
705
populatePojoInternal (fieldValue , pojoAttributeAnnotations ,
712
706
manufacturingCtx , genericTypeArgsAll );
713
707
manufacturingCtx .getPojos ().put (fieldClass , depth );
714
- manufacturingCtx .setTypeArgsMap ( typeArgsMap );
708
+ manufacturingCtx .restoreTypeArgsMap ( );
715
709
} else {
716
710
717
711
LOG .warn ("Loop of depth " + depth + " in filling read-only field {} detected." ,
@@ -1221,12 +1215,11 @@ private void fillCollection(ManufacturingContext manufacturingCtx,
1221
1215
1222
1216
if (null == element ) {
1223
1217
1224
- final Map <String , Type > typeArgsMap = manufacturingCtx .getTypeArgsMap ();
1225
- manufacturingCtx .setTypeArgsMap (NULL_TYPE_ARGS_MAP );
1218
+ manufacturingCtx .backupTypeArgsMap (manufacturingCtx .createEmptyTypeArgsMap ());
1226
1219
element = manufactureAttributeValue (collection , manufacturingCtx ,
1227
1220
collectionElementType , collectionElementType ,
1228
1221
annotations , attributeName , genericTypeArgs );
1229
- manufacturingCtx .setTypeArgsMap ( typeArgsMap );
1222
+ manufacturingCtx .restoreTypeArgsMap ( );
1230
1223
}
1231
1224
1232
1225
if (null != element ) {
@@ -1549,8 +1542,7 @@ private Object getMapKeyOrElementValue(
1549
1542
1550
1543
if (null == retValue ) {
1551
1544
1552
- final Map <String , Type > typeArgsMap = manufacturingCtx .getTypeArgsMap ();
1553
- manufacturingCtx .setTypeArgsMap (NULL_TYPE_ARGS_MAP );
1545
+ manufacturingCtx .backupTypeArgsMap (manufacturingCtx .createEmptyTypeArgsMap ());
1554
1546
retValue = manufactureAttributeValue (
1555
1547
keyOrElementsArguments .getMapToBeFilled (),
1556
1548
manufacturingCtx ,
@@ -1559,7 +1551,7 @@ private Object getMapKeyOrElementValue(
1559
1551
keyOrElementsArguments .getAnnotations (),
1560
1552
keyOrElementsArguments .getAttributeName (),
1561
1553
keyOrElementsArguments .getGenericTypeArgs ());
1562
- manufacturingCtx .setTypeArgsMap ( typeArgsMap );
1554
+ manufacturingCtx .restoreTypeArgsMap ( );
1563
1555
}
1564
1556
return retValue ;
1565
1557
}
@@ -1885,12 +1877,11 @@ private Object manufactureParameterValue(Class<?> pojoClass,
1885
1877
typeArgsMapForParam = manufacturingCtx .getTypeArgsMap ();
1886
1878
}
1887
1879
1888
- final Map <String , Type > typeArgsMap = manufacturingCtx .getTypeArgsMap ();
1889
- manufacturingCtx .setTypeArgsMap (typeArgsMapForParam );
1880
+ manufacturingCtx .backupTypeArgsMap (typeArgsMapForParam );
1890
1881
Object retValue = manufactureAttributeValue (pojoClass , manufacturingCtx , parameterType ,
1891
1882
genericType , annotations , parameterName ,
1892
1883
genericTypeArgs );
1893
- manufacturingCtx .setTypeArgsMap ( typeArgsMap );
1884
+ manufacturingCtx .restoreTypeArgsMap ( );
1894
1885
return retValue ;
1895
1886
}
1896
1887
0 commit comments