how can i find the best lambda list available? closed

You could create a custom Comparator with this logic, and then stream the allOffers list and get its minimum according to that Comparator:

private static Offer getBestOffer(List<Offer> allOffers, int amount) {
    Comparator<Offer> cmp =
        Comparator.comparing(o -> 
            o.getBasicCosts().add(o.getUnitPrice().multiply(new BigDecimal(amount))));

    return allOffers.stream().min(cmp).orElse(null);
}

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top