I have structure map of maps like:
Map<Center, Map<Product, Value>> given
and I want to get
Map<Product, Map<Center, Value>> result
I've used Java streams
Map<Product, Map<Center, Value>> result = given.entrySet().stream()
.flatMap(entry -> entry.getValue()
.entrySet().stream()
.map(e -> Triple(entry.getKey(), e.getKey(), e.getValue())))
.collect(Collectors.groupingBy(Triple::getProduct,
Collectors.toMap(Triple::getCenter, Triple::getValue)));
where Triple is simple value class. My questions is if it is possible to do it functional without using additional classes like Triple or e.g. Table from guava?