Class TargetLineItemOfferDetailComparator
java.lang.Object
com.broadleafcommerce.promotion.offer.service.dto.comparator.TargetLineItemOfferDetailComparator
- All Implemented Interfaces:
Comparator<LineItemOfferDetail>
public class TargetLineItemOfferDetailComparator
extends Object
implements Comparator<LineItemOfferDetail>
Comparator for LineItemOfferDetails being used as targets of
offers. Orders by either the standard or sale price of the details' LineItems.
AComparatorwas used instead ofLineItemOfferDetailimplementingComparablebecause we need a flag to determine whether to use the sale price or standard price in the comparison. SeeuseSalePrice.
- Author:
- Nathan Moore (nathanmoore).
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionTargetLineItemOfferDetailComparator(boolean useSalePrice, String targetGroupingStrategy) -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanintOrders by highest amount first.booleanThe target grouping strategy.inthashCode()booleanDetermines whether to compareLineItemOfferDetailsusing theirEnhancedLineItem.getSalePrice()instead ofEnhancedLineItem.getStandardPrice().voidsetTargetGroupingStrategy(String targetGroupingStrategy) The target grouping strategy.voidsetUseSalePrice(boolean useSalePrice) Determines whether to compareLineItemOfferDetailsusing theirEnhancedLineItem.getSalePrice()instead ofEnhancedLineItem.getStandardPrice().toString()Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Comparator
reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
Constructor Details
-
TargetLineItemOfferDetailComparator
-
TargetLineItemOfferDetailComparator
public TargetLineItemOfferDetailComparator()
-
-
Method Details
-
compare
Orders by highest amount first.- Specified by:
comparein interfaceComparator<LineItemOfferDetail>
-
isUseSalePrice
public boolean isUseSalePrice()Determines whether to compareLineItemOfferDetailsusing theirEnhancedLineItem.getSalePrice()instead ofEnhancedLineItem.getStandardPrice().- Returns:
- whether to compare
LineItemOfferDetailsusing theirEnhancedLineItem.getSalePrice()instead ofEnhancedLineItem.getStandardPrice().
-
getTargetGroupingStrategy
The target grouping strategy. Affects how the item comparison is performed, using either COSTLIEST (default) or CHEAPEST- See Also:
-
setUseSalePrice
public void setUseSalePrice(boolean useSalePrice) Determines whether to compareLineItemOfferDetailsusing theirEnhancedLineItem.getSalePrice()instead ofEnhancedLineItem.getStandardPrice().- Parameters:
useSalePrice- whether to compareLineItemOfferDetailsusing theirEnhancedLineItem.getSalePrice()instead ofEnhancedLineItem.getStandardPrice().
-
setTargetGroupingStrategy
The target grouping strategy. Affects how the item comparison is performed, using either COSTLIEST (default) or CHEAPEST- See Also:
-
equals
- Specified by:
equalsin interfaceComparator<LineItemOfferDetail>- Overrides:
equalsin classObject
-
canEqual
-
hashCode
public int hashCode() -
toString
-