I have a nested HashMap
in this form:
{key1=val1, key2=val2,
key3=[
{key4=val4, key5=val5},
{key6=val6, key7=val7}
]
}
I now want to flatten that map, so that all entries are on the same level:
{key1=val1, key2=val2, key4=val4, key5=val5,key6=val6, key7=val7}
When I try
map.values().forEach(map.get("key3")::addAll);
as described in this post, I get the following error:
invalid method reference
cannot find symbol
symbol: method addAll(T)
location: class Object
where T is a type-variable:
T extends Object declared in interface Iterable
Is there any generic way to flatten any given Map
?