Class PriceDetailComparator
java.lang.Object
com.broadleafcommerce.pricing.service.PriceDetailComparator
- All Implemented Interfaces:
Serializable
,Comparator<com.broadleafcommerce.pricing.client.domain.PriceDetailComparable>
public class PriceDetailComparator
extends Object
implements Comparator<com.broadleafcommerce.pricing.client.domain.PriceDetailComparable>, Serializable
Comparator
for PriceListPriceDetail
used to determine the best price for a
PriceableTarget
. The default puts nulls last except for prices where null is equal to
zero. This comparator compares in order:
- Whether the two details are null, nulls last
- The
PriceListPriceDetail.getPriceListPriority()
, nulls last - The
PriceListPriceDetail.getPriority()
, nulls last - The
PriceListPriceDetail.getPrice()
, null equals 0 - The
PriceListPriceDetail.getRecurringPriceDetail()
, nulls first. If neither are null, comparesRecurringPriceDetail.getPrice()
, null equals 0. - The
PriceListPriceDetail.getUsagePriceDetail()
, nulls first. If neither are null, comparesRecurringPriceDetail.getPrice()
, null equals 0.
- Author:
- Nathan Moore (nathandmoore)
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
compare
(com.broadleafcommerce.pricing.client.domain.PriceDetailComparable a, com.broadleafcommerce.pricing.client.domain.PriceDetailComparable b) protected boolean
isGreaterThanZero
(javax.money.MonetaryAmount a) protected boolean
isZero
(javax.money.MonetaryAmount a) 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
-
PriceDetailComparator
public PriceDetailComparator()
-
-
Method Details
-
compare
public int compare(com.broadleafcommerce.pricing.client.domain.PriceDetailComparable a, com.broadleafcommerce.pricing.client.domain.PriceDetailComparable b) - Specified by:
compare
in interfaceComparator<com.broadleafcommerce.pricing.client.domain.PriceDetailComparable>
-
isZero
protected boolean isZero(@Nullable javax.money.MonetaryAmount a) -
isGreaterThanZero
protected boolean isGreaterThanZero(@Nullable javax.money.MonetaryAmount a)
-