1010
1111import java .lang .reflect .Type ;
1212import java .util .Properties ;
13+ import org .seedstack .coffig .Coffig ;
1314import org .seedstack .coffig .TreeNode ;
1415import org .seedstack .coffig .node .MapNode ;
15- import org .seedstack .coffig .node .ValueNode ;
1616import org .seedstack .coffig .spi .ConfigurationMapper ;
1717
1818public class PropertiesMapper implements ConfigurationMapper {
19+ private Coffig coffig ;
20+
21+ @ Override
22+ public void initialize (Coffig coffig ) {
23+ this .coffig = coffig ;
24+ }
25+
1926 @ Override
2027 public boolean canHandle (Type type ) {
2128 return type instanceof Class && type .equals (Properties .class );
@@ -26,7 +33,8 @@ public Object map(TreeNode treeNode, Type type) {
2633 Properties properties = new Properties ();
2734 if (treeNode .type () == TreeNode .Type .MAP_NODE ) {
2835 treeNode .namedNodes ()
29- .forEach (namedNode -> properties .setProperty (namedNode .name (), namedNode .node ().value ()));
36+ .forEach (namedNode -> properties .setProperty (namedNode .name (),
37+ (String ) coffig .getMapper ().map (namedNode .node (), String .class )));
3038 } else {
3139 treeNode .nodes ().forEach (item -> properties .setProperty (item .value (), "" ));
3240 }
@@ -38,7 +46,7 @@ public TreeNode unmap(Object object, Type type) {
3846 MapNode mapNode = new MapNode ();
3947 ((Properties ) object ).forEach ((key , value ) -> {
4048 if (key != null ) {
41- mapNode .set (String .valueOf (key ), new ValueNode ( String . valueOf (value ) ));
49+ mapNode .set (String .valueOf (key ), coffig . getMapper (). unmap (value , String . class ));
4250 }
4351 });
4452 return mapNode ;
0 commit comments