Java: How do you declare a nested map within spring?

For example, how would you declare a triple map of the type -

Map<String, Map<String, Map<Boolean, String>>>, with the keys being someKey1, someKey2, and someKey3 (true/false)? 

I know before that -

 <util:map id="someMap" map-class="java.util.HashMap" key-type="java.lang.String" value-type="java.lang.String"> <entry key="someKey1" value="someValue" /> </util:map> 

EDIT:

Ok, this is what I want to do to reduce the number of if statements.

 123: //some key 1 abc: //some key 2 true: //some key 3 a //some value false: //some key 3 b //some value 456: def: true: c false: d 

Thanks a lot.

+3
source share
2 answers

Maybe this will work:

 <util:map id="someMap"> <entry key="123"> <value> <map> <entry key="abc"> <value> <map key-type="java.lang.Boolean"> <entry key="true" value="a"/> <entry key="false" value="b"/> </map> </value> </entry> </map> </value> </entry> <entry key="456"> <value> <map> <entry key="def"> <value> <map key-type="java.lang.Boolean"> <entry key="true" value="c"/> <entry key="false" value="d"/> </map> </value> </entry> </map> </value> </entry> </util:map> 
+6
source

Did you really get Adam code to compile? I had to remove external value tags in order for them to work.

 <util:map id="someMap"> <entry key="123"> <map> <entry key="abc"> <map key-type="java.lang.Boolean"> <entry key="true" value="a"/> <entry key="false" value="b"/> </map> </entry> </map> </entry> <entry key="456"> <map> <entry key="def"> <map key-type="java.lang.Boolean"> <entry key="true" value="c"/> <entry key="false" value="d"/> </map> </entry> </map> </entry> </util:map> 

Or am I missing something? =)

+5
source

Source: https://habr.com/ru/post/1315734/


All Articles