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>
ComparatorforLineItemOfferDetailsbeing used as targets of offers. Orders by either the standard or sale price of the details'LineItems.A
Comparatorwas 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:
EnhancedLineItem,LineItemOfferDetail
-
-
Constructor Summary
Constructors Constructor Description TargetLineItemOfferDetailComparator()TargetLineItemOfferDetailComparator(boolean useSalePrice, String targetGroupingStrategy)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected booleancanEqual(Object other)intcompare(LineItemOfferDetail o1, LineItemOfferDetail o2)Orders by highest amount first.booleanequals(Object o)StringgetTargetGroupingStrategy()The target grouping strategy.inthashCode()booleanisUseSalePrice()Determines 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().StringtoString()-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Comparator
reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
-
-
-
Constructor Detail
-
TargetLineItemOfferDetailComparator
public TargetLineItemOfferDetailComparator(boolean useSalePrice, String targetGroupingStrategy)
-
TargetLineItemOfferDetailComparator
public TargetLineItemOfferDetailComparator()
-
-
Method Detail
-
compare
public int compare(LineItemOfferDetail o1, LineItemOfferDetail o2)
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
public String getTargetGroupingStrategy()
The target grouping strategy. Affects how the item comparison is performed, using either COSTLIEST (default) or CHEAPEST- See Also:
TargetGroupingStrategy
-
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
public void setTargetGroupingStrategy(String targetGroupingStrategy)
The target grouping strategy. Affects how the item comparison is performed, using either COSTLIEST (default) or CHEAPEST- See Also:
TargetGroupingStrategy
-
equals
public boolean equals(Object o)
- Specified by:
equalsin interfaceComparator<LineItemOfferDetail>- Overrides:
equalsin classObject
-
canEqual
protected boolean canEqual(Object other)
-
-