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 over DefaultPriceListPriceSources.BLC_PRICE_LIST_FORMULA, and then everything else.
  • PriceableTarget.getTargetType() with CartPricingTargetType.SKU takes precedence
  • Finally, the lowest price wins
Since:
2.1.0
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)
    • compareByTargetType

      protected int compareByTargetType(com.broadleafcommerce.pricing.client.domain.PriceInfo p1, com.broadleafcommerce.pricing.client.domain.PriceInfo p2)
      Compares by the PriceableTarget.getTargetType().

      CartPricingTargetType.SKU takes precedence by default.