Interface CartDiscountPatternTarget
- All Superinterfaces:
CartDiscountTarget
Pattern targets can be used to model Buy and Get discounts.
Unlike CartDiscountLineItemsTarget and CartDiscountCustomLineItemsTarget, it does not apply to a (Custom) Line Item as a whole, but to individual units of a (Custom) Line Item. The discounts can apply multiple times on the same cart, but each unit can be discounted only once.
Example to create an instance using the builder pattern
CartDiscountPatternTarget cartDiscountPatternTarget = CartDiscountPatternTarget.builder()
.plusTriggerPattern(triggerPatternBuilder -> triggerPatternBuilder)
.plusTargetPattern(targetPatternBuilder -> targetPatternBuilder)
.selectionMode(SelectionMode.CHEAPEST)
.build()
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionbuilder()
builder factory method for CartDiscountPatternTargetbuilder
(CartDiscountPatternTarget template) create builder for CartDiscountPatternTarget instancestatic CartDiscountPatternTarget
deepCopy
(CartDiscountPatternTarget template) factory method to create a deep copy of CartDiscountPatternTargetMaximum number of times the Discount can apply on a Cart.@NotNull SelectionMode
Determines which of the matching units of (Custom) Line Items are discounted.@NotNull @Valid List<PatternComponent>
Defines the set of units of (Custom) Line Items in a Cart on which the Discount is applied.@NotNull @Valid List<PatternComponent>
Defines the set of units of (Custom) Line Items in a Cart that trigger a discount application.static CartDiscountPatternTarget
of()
factory methodstatic CartDiscountPatternTarget
of
(CartDiscountPatternTarget template) factory method to create a shallow copy CartDiscountPatternTargetvoid
setMaxOccurrence
(Integer maxOccurrence) Maximum number of times the Discount can apply on a Cart.void
setSelectionMode
(SelectionMode selectionMode) Determines which of the matching units of (Custom) Line Items are discounted.void
setTargetPattern
(PatternComponent... targetPattern) Defines the set of units of (Custom) Line Items in a Cart on which the Discount is applied.void
setTargetPattern
(List<PatternComponent> targetPattern) Defines the set of units of (Custom) Line Items in a Cart on which the Discount is applied.void
setTriggerPattern
(PatternComponent... triggerPattern) Defines the set of units of (Custom) Line Items in a Cart that trigger a discount application.void
setTriggerPattern
(List<PatternComponent> triggerPattern) Defines the set of units of (Custom) Line Items in a Cart that trigger a discount application.static com.fasterxml.jackson.core.type.TypeReference<CartDiscountPatternTarget>
gives a TypeReference for usage with Jackson DataBinddefault <T> T
accessor map functionMethods inherited from interface com.commercetools.api.models.cart_discount.CartDiscountTarget
getType, withCartDiscountTarget
-
Field Details
-
PATTERN
discriminator value for CartDiscountPatternTarget- See Also:
-
-
Method Details
-
getTriggerPattern
Defines the set of units of (Custom) Line Items in a Cart that trigger a discount application.
Based on the availability of matching units, the
triggerPattern
can match multiple times, limiting the number of maximum times the discount will be applied. To further limit the discount application, set themaxOccurrence
.If empty, the Discount will apply indefinitely.
- Returns:
- triggerPattern
-
getTargetPattern
Defines the set of units of (Custom) Line Items in a Cart on which the Discount is applied.
Based on the availability of matching units and the limits from the
triggerPattern
ormaxOccurence
, thetargetPattern
can match multiple times.This array cannot be empty.
- Returns:
- targetPattern
-
getMaxOccurrence
Integer getMaxOccurrence()Maximum number of times the Discount can apply on a Cart.
If empty or not set, the Discount will apply indefinitely.
- Returns:
- maxOccurrence
-
getSelectionMode
Determines which of the matching units of (Custom) Line Items are discounted.
- Returns:
- selectionMode
-
setTriggerPattern
Defines the set of units of (Custom) Line Items in a Cart that trigger a discount application.
Based on the availability of matching units, the
triggerPattern
can match multiple times, limiting the number of maximum times the discount will be applied. To further limit the discount application, set themaxOccurrence
.If empty, the Discount will apply indefinitely.
- Parameters:
triggerPattern
- values to be set
-
setTriggerPattern
Defines the set of units of (Custom) Line Items in a Cart that trigger a discount application.
Based on the availability of matching units, the
triggerPattern
can match multiple times, limiting the number of maximum times the discount will be applied. To further limit the discount application, set themaxOccurrence
.If empty, the Discount will apply indefinitely.
- Parameters:
triggerPattern
- values to be set
-
setTargetPattern
Defines the set of units of (Custom) Line Items in a Cart on which the Discount is applied.
Based on the availability of matching units and the limits from the
triggerPattern
ormaxOccurence
, thetargetPattern
can match multiple times.This array cannot be empty.
- Parameters:
targetPattern
- values to be set
-
setTargetPattern
Defines the set of units of (Custom) Line Items in a Cart on which the Discount is applied.
Based on the availability of matching units and the limits from the
triggerPattern
ormaxOccurence
, thetargetPattern
can match multiple times.This array cannot be empty.
- Parameters:
targetPattern
- values to be set
-
setMaxOccurrence
Maximum number of times the Discount can apply on a Cart.
If empty or not set, the Discount will apply indefinitely.
- Parameters:
maxOccurrence
- value to be set
-
setSelectionMode
Determines which of the matching units of (Custom) Line Items are discounted.
- Parameters:
selectionMode
- value to be set
-
of
factory method- Returns:
- instance of CartDiscountPatternTarget
-
of
factory method to create a shallow copy CartDiscountPatternTarget- Parameters:
template
- instance to be copied- Returns:
- copy instance
-
deepCopy
factory method to create a deep copy of CartDiscountPatternTarget- Parameters:
template
- instance to be copied- Returns:
- copy instance
-
builder
builder factory method for CartDiscountPatternTarget- Returns:
- builder
-
builder
create builder for CartDiscountPatternTarget instance- Parameters:
template
- instance with prefilled values for the builder- Returns:
- builder
-
withCartDiscountPatternTarget
accessor map function- Type Parameters:
T
- mapped type- Parameters:
helper
- function to map the object- Returns:
- mapped value
-
typeReference
gives a TypeReference for usage with Jackson DataBind- Returns:
- TypeReference
-