As far as I know Java 8 introduces a new method available for Collection types: removeif(). It accepts a predicate which defines the condition on which the elements should be removed. It returns a boolean where a true response means that at least one item has been removed and false otherwise: I have this class:
HotelPriceSummary {
Hotel hotel;
float price
}
a List<HotelPriceSummary> allHotels;
and Iterable<Hotel> discardedHotels
I would like to do something like (obviously existsIn is a functions that does not exist, is to express what I would like to do but I didn't find the way)
allHotels.removeIf(h -> h.getHotel().existsIn (discardedHotels))