title: How do I Combine/Merge two Map of Map of Lists (Map<String, Map<Enum, List<String>>>) in Java 8
body: <p>Given:
  A Map containing FRUITS</p>
  
  <pre><code>enum Food{
  FRUITS, VEGGIES;
  }
  
  Map&lt;String, Map&lt;Food, List&lt;String&gt;&gt;&gt; fruitBasket= new HashMap&lt;&gt;();
  fruitBasket.put("basket1", Collections.singletonMap(Food.FRUITS, Arrays.asList("apple","banana")));
  fruitBasket.put("basket2", Collections.singletonMap(Food.FRUITS, Arrays.asList"orange", "kiwi")));
  fruitBasket.put("basket3", Collections.singletonMap(Food.FRUITS, Arrays.asList("banana", "orange")));
  
  fruitBasket:
  [
  basket1, [Food.FRUITS, {"apple", "banana"}],
  basket2, [Food.FRUITS, {"orange", "kiwi"}],
  basket3, [Food.FRUITS, {"banana", "orange"}]
  ]
  </code></pre>
  
  <p>Similarly another map containing VEGGIES</p>
  
  <pre><code>Map&lt;String, Map&lt;Food, List&lt;String&gt;&gt;&gt; veggieBasket= new HashMap&lt;&gt;();
  veggieBasket.put("basket1", Collections.singletonMap(Food.VEGGIES, Arrays.asList("Tomato","Onion")));
  veggieBasket.put("basket2", Collections.singletonMap(Food.VEGGIES, Arrays.asList("Onion", "Potato")));
  veggieBasket.put("basket3", Collections.singletonMap(Food.VEGGIES, Arrays.asList("Potato", "Tomato")));
  
  veggieBasket:
  [
  basket1, [Food.VEGGIES, {"Tomato","Onion"}],
  basket2, [Food.VEGGIES, {"Onion", "Potato"}],
  basket3, [Food.VEGGIES, {"Potato", "Tomato"}]
  ]
  </code></pre>
  
  <p>I am trying to combine the baskets <em>fruitBasket</em> and <em>veggieBasket</em> </p>
  
  <pre><code>Final output: should look something like below
  
  groceryBasket
  [
  basket1, [Food.FRUITS, {"apple", "banana"}, Food.VEGGIES, {"Tomato","Onion"}],
  basket2, [Food.FRUITS, {"orange", "kiwi"}, Food.VEGGIES, {"Onion", "Potato"}],
  basket3, [Food.FRUITS, {"banana", "orange"}, Food.VEGGIES, {"Potato", "Tomato"}]
  ]
  </code></pre>
  
  <p>MySolution:</p>
  
  <pre><code>Solution 1:
  Map&lt;String, Map&lt;Food, List&lt;String&gt;&gt;&gt; groceryBasket= new HashMap&lt;&gt;();
  
  grocery basket = Stream.concat(fruitBasket.entrySet().stream(), veggieBasket.entrySet().stream())
                  .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (fruitList, veggieList ) -&gt;
                  {
                      final List&lt;String&gt; groceryList = new ArrayList&lt;&gt;();
                      groceryList .addAll(fruitList);
                      groceryList .addAll(veggieList);
                      return groceryList;
                  }));
  
  Solution 2:
  Map&lt;String, Map&lt;Food, List&lt;String&gt;&gt;&gt; groceryBasket= new HashMap&lt;&gt;();
  
  grocery basket = Stream.concat(fruitBasket.entrySet().stream(), veggieBasket.entrySet().stream())
                  .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (fruitList, veggieList ) -&gt;
                  {
                      return Stream.of(fruitList, veggieList).flatMap(x -&gt; x.stream()).collect(Collectors.toList());
                  }));
  </code></pre>
  
  <p>I tried Solutions 1 and Solution 2, I was trying to thing if there is a better/optimized way to handle this?</p>