Class DiscountTier

java.lang.Object
com.broadleafcommerce.promotion.offer.domain.DiscountTier
All Implemented Interfaces:
com.broadleafcommerce.data.tracking.core.EmbeddedContextStateAware, DiscountAmountTypeHolder, Serializable, Comparable<DiscountTier>

public class DiscountTier extends Object implements Serializable, Comparable<DiscountTier>, com.broadleafcommerce.data.tracking.core.EmbeddedContextStateAware, DiscountAmountTypeHolder
Represents a tier and amount combination for an offer's discount. For example, an offer might allow a 10% off if a user purchases 1 through 5 of the same item but then allow 15% off if they purchase more than 5 of that item.
Note that tiers only apply to item offers—not orders or fulfillment groups.
Author:
Chad Harchar (charchar)
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected BigDecimal
    The discount amount that this tier represents.
    protected String
    Determines the method used to apply the discount.
    protected BigDecimal
    The minimum currency amount to qualify for this tier.
    protected Long
    The minimum quantity of items needed to reach this tier.

    Fields inherited from interface com.broadleafcommerce.data.tracking.core.EmbeddedContextStateAware

    DEFAULT_FIELD_NAME
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected boolean
     
    int
    Compares priorities.
    boolean
     
    The discount amount that this tier represents.
    com.broadleafcommerce.data.tracking.core.EmbeddedContextState
    A subset of Tracking information to expose the context state for this object.
    Determines the method used to apply the discount.
    The minimum currency amount to qualify for this tier.
    The minimum quantity of items needed to reach this tier.
    int
     
    void
    The discount amount that this tier represents.
    void
    setContextState(com.broadleafcommerce.data.tracking.core.EmbeddedContextState contextState)
    A subset of Tracking information to expose the context state for this object.
    void
    setMethodType(String methodType)
    Determines the method used to apply the discount.
    void
    The minimum currency amount to qualify for this tier.
    void
    setMinQuantity(Long minQuantity)
    The minimum quantity of items needed to reach this tier.
     

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

  • Constructor Details

    • DiscountTier

      public DiscountTier()
  • Method Details

    • compareTo

      public int compareTo(@NonNull DiscountTier that)
      Compares priorities. Null is less than non-null.
      Specified by:
      compareTo in interface Comparable<DiscountTier>
      Parameters:
      that - DiscountTier to which we are comparing
      Returns:
      a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
    • getMinQuantity

      public Long getMinQuantity()
      The minimum quantity of items needed to reach this tier.
    • getMinAmount

      public BigDecimal getMinAmount()
      The minimum currency amount to qualify for this tier.
    • getAmount

      public BigDecimal getAmount()
      The discount amount that this tier represents. If the amount is 10, then whether it is calculated as a percentage (10%) or a currency amount ($10) is determined by methodType. Overrides Discount.amount of the parent Offer.
      Specified by:
      getAmount in interface DiscountAmountTypeHolder
    • getMethodType

      public String getMethodType()
      Determines the method used to apply the discount. The method can be DiscountMethodType.PERCENT_OFF, DiscountMethodType.AMOUNT_OFF, or DiscountMethodType.FIXED_PRICE. Overrides Discount.methodType of the parent Offer.
      Specified by:
      getMethodType in interface DiscountAmountTypeHolder
      Returns:
      The method to use to apply this discount
      See Also:
    • getContextState

      public com.broadleafcommerce.data.tracking.core.EmbeddedContextState getContextState()
      A subset of Tracking information to expose the context state for this object. This value is not persisted, and instead it is dynamically calculated and populated when the ChangeDetails for the parent object's entire attributes map are compared.
      Specified by:
      getContextState in interface com.broadleafcommerce.data.tracking.core.EmbeddedContextStateAware
      Returns:
      a subset of Tracking information to expose the context state for this object
    • setMinQuantity

      public void setMinQuantity(Long minQuantity)
      The minimum quantity of items needed to reach this tier.
    • setMinAmount

      public void setMinAmount(BigDecimal minAmount)
      The minimum currency amount to qualify for this tier.
    • setAmount

      public void setAmount(BigDecimal amount)
      The discount amount that this tier represents. If the amount is 10, then whether it is calculated as a percentage (10%) or a currency amount ($10) is determined by methodType. Overrides Discount.amount of the parent Offer.
    • setMethodType

      public void setMethodType(String methodType)
      Determines the method used to apply the discount. The method can be DiscountMethodType.PERCENT_OFF, DiscountMethodType.AMOUNT_OFF, or DiscountMethodType.FIXED_PRICE. Overrides Discount.methodType of the parent Offer.
      Parameters:
      methodType - The method to use to apply this discount
      See Also:
    • setContextState

      public void setContextState(com.broadleafcommerce.data.tracking.core.EmbeddedContextState contextState)
      A subset of Tracking information to expose the context state for this object. This value is not persisted, and instead it is dynamically calculated and populated when the ChangeDetails for the parent object's entire attributes map are compared.
      Specified by:
      setContextState in interface com.broadleafcommerce.data.tracking.core.EmbeddedContextStateAware
      Parameters:
      contextState - a subset of Tracking information to expose the context state for this object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • canEqual

      protected boolean canEqual(Object other)
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object