@Override
public List<PromotableOrderItem> getDiscountableOrderItems(boolean applyDiscountToSalePrice) {
if (discountableOrderItems == null || discountableOrderItems.isEmpty()) {
discountableOrderItems = buildPromotableOrderItemsList();
OrderItemPriceComparator priceComparator = new OrderItemPriceComparator(applyDiscountToSalePrice);
// Sort the items so that the highest priced ones are at the top
Collections.sort(discountableOrderItems, priceComparator);
currentSortParam = applyDiscountToSalePrice;
}
if (currentSortParam != applyDiscountToSalePrice) {
// Resort
OrderItemPriceComparator priceComparator = new OrderItemPriceComparator(applyDiscountToSalePrice);
Collections.sort(discountableOrderItems, priceComparator);
currentSortParam = applyDiscountToSalePrice;
}