Suppose there is a class:
class A {
long sent;
long received;
double val;
}
of which there are a number of references to instances in Map<String , A>.
Is it possible in one motion, using the stream API, to return an instance of class A with the following properties:
- sent = sum of sent fields from all instances
- received = sum of received fields from all instances in Map
- val = maximum value of val, given all entries, where val = max {sent / someDenominator, received / someDenominator}
What would be a trivial task using the standard for a loop and one iteration, I don’t know how to achieve using the stream API.
source
share