I have a class that holds details of a particular item like the following:
Detail.class
Long detailsId;
Integer price;
List<Long> stackableDetails;
/*getters and setters*/
Now, I have a sample dataset like the following:
DetailId Price StackableDetails
------------------------------------------
1011 4$ 1012, 1014
1012 6$ 1011,1013
1013 10$ 1012
1014 8$ 1011
This data set maps to List sampleDetails. Now, based on the stackableDetails information, I have to combine the details and pick the combination having the max price from it.
For eg,
In the data set available, the possible combinations would be
1011,1012,1014 - 4+6+8 = 18$
1012,1011,1013 - 6+4+10 = 20$
1013,1012 - 10+6 = 16$
1014,1011 - 8+4 = 12$
Now the combination of details 1012,1011,1013 yields 20$, so I fetch this combination and add this in my result list. How can I achieve this in java8.
Any help appreciated. Thanks!