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:
  1. Whether the two details are null, nulls last
  2. The PriceListPriceDetail.getPriceListPriority(), nulls last
  3. The PriceListPriceDetail.getPriority(), nulls last
  4. The PriceListPriceDetail.getPrice(), null equals 0
  5. The PriceListPriceDetail.getRecurringPriceDetail(), nulls first. If neither are null, compares RecurringPriceDetail.getPrice(), null equals 0.
  6. The PriceListPriceDetail.getUsagePriceDetail(), nulls first. If neither are null, compares RecurringPriceDetail.getPrice(), null equals 0.
Author:
Nathan Moore (nathandmoore)
See Also:
  • 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 interface Comparator<com.broadleafcommerce.pricing.client.domain.PriceDetailComparable>
    • isZero

      protected boolean isZero(@Nullable javax.money.MonetaryAmount a)
    • isGreaterThanZero

      protected boolean isGreaterThanZero(@Nullable javax.money.MonetaryAmount a)