-2

Suppose I have a java.util.Map named rootMap. rootMap["level1"] is another Map (let's call it map1) map1["level2] is another Map etc...In short words, I have a Map hierarchy.

My need : simply and directly get a deep field with a short API like : get(rootMap, "level1.level2.field") I thought leveraging Dozer but does something simpler exist ? Thanks !

user1458153
  • 115
  • 1
  • 8

2 Answers2

2

If you have a map of maps

HashMap<String, HashMap<String, String>> outerMap = new HashMap<String, HashMap<String, String>>();

You can access some inner map by

outerMap.get("inner map key");

And to get a value of inner map you do

outerMap.get("inner map key").get("the key");

So, as you can see, you have to pipe calls to Map.get in order to get inner maps.

Gabriel
  • 1,922
  • 2
  • 19
  • 37
0

I actually need a Map2POJO mapping, so I finally used Dozer to do that, as previously suggested in Dozer, how to map from java.util.Map to complex type?

Community
  • 1
  • 1
user1458153
  • 115
  • 1
  • 8