Class ItemCriteria

java.lang.Object
com.broadleafcommerce.promotion.offer.domain.ItemCriteria
All Implemented Interfaces:
Serializable

public class ItemCriteria extends Object implements Serializable
Encapsulates all criteria used either to determine if an item is a qualifier or a target.
  • An "item qualifier" is an item that qualifies its order or other items to receive an offer's discount.
  • A "target item" is an item that can receive an offer's discount.

Each criteria is made up of 1 or more Rules. A rule is represented as an string expression, using Spring Expression Language by default: itemName.contains('some name') and itemPrice > 10.99. It also provides additional granularity to a criteria by allowing a restriction on how many matches are required for the rule: Apply this offer when there are 2 items where itemName.contains('some name') and itemPrice > 10.99 in the order. If there were 4 such items, then this offer could be applied twice to the order (once per set of complete matches).

The criteria also provides control over its rules are connected logically: Thus, you can make a criteria equivalent to "Apply this offer when there are, rule 1, 2 hats with prices greater than $10 and, rule 2, 1 tie or belt with price greater than $10."

Author:
Nathan Moore (nathanmoore).
See Also:
  • Constructor Details

    • ItemCriteria

      public ItemCriteria(Set<ItemCriteriaRule> rules)
      Convenience constructor to initialize rules.
      Parameters:
      rules -
    • ItemCriteria

      public ItemCriteria()
    • ItemCriteria

      public ItemCriteria(String connectiveOperator, Set<ItemCriteriaRule> rules)
  • Method Details

    • getConnectiveOperator

      public String getConnectiveOperator()
      The connective with which to join all of the rules together. Individual rules can also have separate sub-rules connected with unrelated operators.
      Returns:
      The connective with which to join all of the rules together.
      See Also:
      • DefaultConnectiveOperatorType
    • getRules

      public Set<ItemCriteriaRule> getRules()
      Rules that comprise this criteria. When multiple rules are present, they will be connected with connectiveOperator.
      Returns:
      The rules that comprise this criteria.
    • setConnectiveOperator

      public void setConnectiveOperator(String connectiveOperator)
      The connective with which to join all of the rules together. Individual rules can also have separate sub-rules connected with unrelated operators.
      Parameters:
      connectiveOperator - The connective with which to join all of the rules together.
      See Also:
      • DefaultConnectiveOperatorType
    • setRules

      public void setRules(Set<ItemCriteriaRule> rules)
      Rules that comprise this criteria. When multiple rules are present, they will be connected with connectiveOperator.
      Parameters:
      rules - Rules that comprise this criteria.
    • 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
    • toString

      public String toString()
      Overrides:
      toString in class Object