I have a map in java that is an instance of the following:
Map< K1,Map< K2, List<Object>>>
I want to convert it to the following structure:
Map< K1, Map< K2, LinkedHashMap<Object, Value>>>
Where Value is a property of Object. I also want to preserve the order in the list to the HashMap.
I found some similar code examples of what i am trying to achieve but not the same. I appreciate any help i can get.
Please try this. Assume the first map is
fooand the second map (with LinkedHashMap) isbar.Note that it only works if the elements in each list are unique, otherwise the same key would be re-inserted into the LinkedHashMap, which does not affect the insertion order.
I may make some silly mistake in the implementation above, please do comment and edit in that case.