Class PriceInfoComparator
java.lang.Object
com.broadleafcommerce.cartoperation.service.pricing.PriceInfoComparator
- All Implemented Interfaces:
Comparator<com.broadleafcommerce.pricing.client.domain.PriceInfo>
public class PriceInfoComparator
extends Object
implements Comparator<com.broadleafcommerce.pricing.client.domain.PriceInfo>
A comparator for comparing
PriceInfo
based on the precedence of each price according to
this priority:
- Whether it's from a Price List. A price from a Price List takes precedence over a non-PriceList price, e.g. product's default price
- If it is from a Price List, compares the price source.
DefaultPriceListPriceSources.BLC_PRICE_LIST_PRICE_DATA
takes precedence overDefaultPriceListPriceSources.BLC_PRICE_LIST_FORMULA
, and then everything else. PriceableTarget.getTargetType()
withCartPricingTargetType.SKU
takes precedence- Finally, the lowest price wins
- Since:
- 2.1.0
- Author:
- Sunny Yu
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionint
compare
(com.broadleafcommerce.pricing.client.domain.PriceInfo p1, com.broadleafcommerce.pricing.client.domain.PriceInfo p2) protected int
compareByPriceList
(com.broadleafcommerce.pricing.client.domain.PriceInfo p1, com.broadleafcommerce.pricing.client.domain.PriceInfo p2) protected int
compareByPriceListPriceSource
(com.broadleafcommerce.pricing.client.domain.PriceInfo p1, com.broadleafcommerce.pricing.client.domain.PriceInfo p2) protected int
compareByTargetType
(com.broadleafcommerce.pricing.client.domain.PriceInfo p1, com.broadleafcommerce.pricing.client.domain.PriceInfo p2) Compares by thePriceableTarget.getTargetType()
.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.Comparator
equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
Constructor Details
-
PriceInfoComparator
public PriceInfoComparator()
-
-
Method Details
-
compare
public int compare(com.broadleafcommerce.pricing.client.domain.PriceInfo p1, com.broadleafcommerce.pricing.client.domain.PriceInfo p2) - Specified by:
compare
in interfaceComparator<com.broadleafcommerce.pricing.client.domain.PriceInfo>
-
compareByPriceList
protected int compareByPriceList(com.broadleafcommerce.pricing.client.domain.PriceInfo p1, com.broadleafcommerce.pricing.client.domain.PriceInfo p2) -
compareByPriceListPriceSource
protected int compareByPriceListPriceSource(com.broadleafcommerce.pricing.client.domain.PriceInfo p1, com.broadleafcommerce.pricing.client.domain.PriceInfo p2) -
compareByTargetType
protected int compareByTargetType(com.broadleafcommerce.pricing.client.domain.PriceInfo p1, com.broadleafcommerce.pricing.client.domain.PriceInfo p2) Compares by thePriceableTarget.getTargetType()
.CartPricingTargetType.SKU
takes precedence by default.
-