Skip to content
Advertisement

Get all elements in flat format from nested set structure

I need to get the data back similar to flatMap but it is not working in some scenario. Following are the details. Below is the pseudo code

JavaScript

The filteredObject in the method getEmployeeSetForLocation on inspection shows containing 1 element and that element is of type Set containing 2 elements. I want to know, what modification can I make in the above logic to flatten the structure further so that filteredObject shows a set with 2 elements. Any pointers will be helpful. I am using Java 8.

Regards

Advertisement

Answer

Use flatMap, mapping the stream of MapEntry to stream of Employee

JavaScript
Advertisement