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
.
AComparator
was used instead ofLineItemOfferDetail
implementingComparable
because 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
ConstructorDescriptionTargetLineItemOfferDetailComparator
(boolean useSalePrice, String targetGroupingStrategy) -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
int
Orders by highest amount first.boolean
The target grouping strategy.int
hashCode()
boolean
Determines whether to compareLineItemOfferDetails
using theirEnhancedLineItem.getSalePrice()
instead ofEnhancedLineItem.getStandardPrice()
.void
setTargetGroupingStrategy
(String targetGroupingStrategy) The target grouping strategy.void
setUseSalePrice
(boolean useSalePrice) Determines whether to compareLineItemOfferDetails
using theirEnhancedLineItem.getSalePrice()
instead ofEnhancedLineItem.getStandardPrice()
.toString()
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 Details
-
TargetLineItemOfferDetailComparator
-
TargetLineItemOfferDetailComparator
public TargetLineItemOfferDetailComparator()
-
-
Method Details
-
compare
Orders by highest amount first.- Specified by:
compare
in interfaceComparator<LineItemOfferDetail>
-
isUseSalePrice
public boolean isUseSalePrice()Determines whether to compareLineItemOfferDetails
using theirEnhancedLineItem.getSalePrice()
instead ofEnhancedLineItem.getStandardPrice()
.- Returns:
- whether to compare
LineItemOfferDetails
using 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 compareLineItemOfferDetails
using theirEnhancedLineItem.getSalePrice()
instead ofEnhancedLineItem.getStandardPrice()
.- Parameters:
useSalePrice
- whether to compareLineItemOfferDetails
using 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:
equals
in interfaceComparator<LineItemOfferDetail>
- Overrides:
equals
in classObject
-
canEqual
-
hashCode
public int hashCode() -
toString
-