java.lang.Object
com.broadleafcommerce.catalogbrowse.service.provider.external.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 over DefaultPriceListPriceSources.BLC_PRICE_LIST_FORMULA, and then everything else.
  • Finally, the lowest price wins
Since:
1.8.8, 2.0.1
Author:
Sunny Yu
  • 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 interface Comparator<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)