Class CartDiscountBuilder

java.lang.Object
com.commercetools.api.models.cart_discount.CartDiscountBuilder
All Implemented Interfaces:
Builder<CartDiscount>

public class CartDiscountBuilder extends Object implements Builder<CartDiscount>
CartDiscountBuilder
Example to create an instance using the builder pattern

     CartDiscount cartDiscount = CartDiscount.builder()
             .id("{id}")
             .version(0.3)
             .createdAt(ZonedDateTime.parse("2022-01-01T12:00:00.301Z"))
             .lastModifiedAt(ZonedDateTime.parse("2022-01-01T12:00:00.301Z"))
             .name(nameBuilder -> nameBuilder)
             .value(valueBuilder -> valueBuilder)
             .cartPredicate("{cartPredicate}")
             .sortOrder("{sortOrder}")
             .plusStores(storesBuilder -> storesBuilder)
             .isActive(true)
             .requiresDiscountCode(true)
             .plusReferences(referencesBuilder -> referencesBuilder)
             .stackingMode(StackingMode.STACKING)
             .build()
 
  • Constructor Details

    • CartDiscountBuilder

      public CartDiscountBuilder()
  • Method Details

    • id

      public CartDiscountBuilder id(String id)

      Unique identifier of the CartDiscount.

      Parameters:
      id - value to be set
      Returns:
      Builder
    • version

      public CartDiscountBuilder version(Long version)

      Current version of the CartDiscount.

      Parameters:
      version - value to be set
      Returns:
      Builder
    • createdAt

      public CartDiscountBuilder createdAt(ZonedDateTime createdAt)

      Date and time (UTC) the CartDiscount was initially created.

      Parameters:
      createdAt - value to be set
      Returns:
      Builder
    • lastModifiedAt

      public CartDiscountBuilder lastModifiedAt(ZonedDateTime lastModifiedAt)

      Date and time (UTC) the CartDiscount was last updated.

      Parameters:
      lastModifiedAt - value to be set
      Returns:
      Builder
    • lastModifiedBy

      IDs and references that last modified the CartDiscount.

      Parameters:
      builder - function to build the lastModifiedBy value
      Returns:
      Builder
    • withLastModifiedBy

      public CartDiscountBuilder withLastModifiedBy(Function<LastModifiedByBuilder,LastModifiedBy> builder)

      IDs and references that last modified the CartDiscount.

      Parameters:
      builder - function to build the lastModifiedBy value
      Returns:
      Builder
    • lastModifiedBy

      public CartDiscountBuilder lastModifiedBy(@Nullable LastModifiedBy lastModifiedBy)

      IDs and references that last modified the CartDiscount.

      Parameters:
      lastModifiedBy - value to be set
      Returns:
      Builder
    • createdBy

      IDs and references that created the CartDiscount.

      Parameters:
      builder - function to build the createdBy value
      Returns:
      Builder
    • withCreatedBy

      public CartDiscountBuilder withCreatedBy(Function<CreatedByBuilder,CreatedBy> builder)

      IDs and references that created the CartDiscount.

      Parameters:
      builder - function to build the createdBy value
      Returns:
      Builder
    • createdBy

      public CartDiscountBuilder createdBy(@Nullable CreatedBy createdBy)

      IDs and references that created the CartDiscount.

      Parameters:
      createdBy - value to be set
      Returns:
      Builder
    • name

      Name of the CartDiscount.

      Parameters:
      builder - function to build the name value
      Returns:
      Builder
    • withName

      Name of the CartDiscount.

      Parameters:
      builder - function to build the name value
      Returns:
      Builder
    • name

      Name of the CartDiscount.

      Parameters:
      name - value to be set
      Returns:
      Builder
    • key

      User-defined unique identifier of the CartDiscount.

      Parameters:
      key - value to be set
      Returns:
      Builder
    • description

      Description of the CartDiscount.

      Parameters:
      builder - function to build the description value
      Returns:
      Builder
    • withDescription

      Description of the CartDiscount.

      Parameters:
      builder - function to build the description value
      Returns:
      Builder
    • description

      public CartDiscountBuilder description(@Nullable LocalizedString description)

      Description of the CartDiscount.

      Parameters:
      description - value to be set
      Returns:
      Builder
    • value

      public CartDiscountBuilder value(CartDiscountValue value)

      Effect of the CartDiscount on the target.

      Parameters:
      value - value to be set
      Returns:
      Builder
    • value

      Effect of the CartDiscount on the target.

      Parameters:
      builder - function to build the value value
      Returns:
      Builder
    • cartPredicate

      public CartDiscountBuilder cartPredicate(String cartPredicate)

      Valid Cart Predicate.

      Parameters:
      cartPredicate - value to be set
      Returns:
      Builder
    • target

      Segment of the Cart that is discounted.

      Empty, if the value is giftLineItem.

      Parameters:
      target - value to be set
      Returns:
      Builder
    • target

      Segment of the Cart that is discounted.

      Empty, if the value is giftLineItem.

      Parameters:
      builder - function to build the target value
      Returns:
      Builder
    • sortOrder

      public CartDiscountBuilder sortOrder(String sortOrder)

      Value between 0 and 1. All matching CartDiscounts are applied to a Cart in the order defined by this field. A Discount with a higher sortOrder is prioritized. The sort order is unambiguous among all CartDiscounts.

      Parameters:
      sortOrder - value to be set
      Returns:
      Builder
    • stores

      public CartDiscountBuilder stores(StoreKeyReference... stores)
      • If a value exists, the Cart Discount applies on Carts having a Store matching any Store defined for this field.
      • If empty, the Cart Discount applies on all Carts, irrespective of a Store.
      Parameters:
      stores - value to be set
      Returns:
      Builder
    • stores

      public CartDiscountBuilder stores(List<StoreKeyReference> stores)
      • If a value exists, the Cart Discount applies on Carts having a Store matching any Store defined for this field.
      • If empty, the Cart Discount applies on all Carts, irrespective of a Store.
      Parameters:
      stores - value to be set
      Returns:
      Builder
    • plusStores

      public CartDiscountBuilder plusStores(StoreKeyReference... stores)
      • If a value exists, the Cart Discount applies on Carts having a Store matching any Store defined for this field.
      • If empty, the Cart Discount applies on all Carts, irrespective of a Store.
      Parameters:
      stores - value to be set
      Returns:
      Builder
    • plusStores

      • If a value exists, the Cart Discount applies on Carts having a Store matching any Store defined for this field.
      • If empty, the Cart Discount applies on all Carts, irrespective of a Store.
      Parameters:
      builder - function to build the stores value
      Returns:
      Builder
    • withStores

      • If a value exists, the Cart Discount applies on Carts having a Store matching any Store defined for this field.
      • If empty, the Cart Discount applies on all Carts, irrespective of a Store.
      Parameters:
      builder - function to build the stores value
      Returns:
      Builder
    • addStores

      • If a value exists, the Cart Discount applies on Carts having a Store matching any Store defined for this field.
      • If empty, the Cart Discount applies on all Carts, irrespective of a Store.
      Parameters:
      builder - function to build the stores value
      Returns:
      Builder
    • setStores

      • If a value exists, the Cart Discount applies on Carts having a Store matching any Store defined for this field.
      • If empty, the Cart Discount applies on all Carts, irrespective of a Store.
      Parameters:
      builder - function to build the stores value
      Returns:
      Builder
    • isActive

      public CartDiscountBuilder isActive(Boolean isActive)

      Indicates if the CartDiscount is active and can be applied to the Cart.

      Parameters:
      isActive - value to be set
      Returns:
      Builder
    • validFrom

      public CartDiscountBuilder validFrom(@Nullable ZonedDateTime validFrom)

      Date and time (UTC) from which the Discount is effective.

      Parameters:
      validFrom - value to be set
      Returns:
      Builder
    • validUntil

      public CartDiscountBuilder validUntil(@Nullable ZonedDateTime validUntil)

      Date and time (UTC) until which the Discount is effective.

      Parameters:
      validUntil - value to be set
      Returns:
      Builder
    • requiresDiscountCode

      public CartDiscountBuilder requiresDiscountCode(Boolean requiresDiscountCode)

      Indicates if the Discount is used in connection with a DiscountCode.

      Parameters:
      requiresDiscountCode - value to be set
      Returns:
      Builder
    • references

      public CartDiscountBuilder references(Reference... references)

      References of all resources that are addressed in the predicate. The API generates this array from the predicate.

      Parameters:
      references - value to be set
      Returns:
      Builder
    • references

      public CartDiscountBuilder references(List<Reference> references)

      References of all resources that are addressed in the predicate. The API generates this array from the predicate.

      Parameters:
      references - value to be set
      Returns:
      Builder
    • plusReferences

      public CartDiscountBuilder plusReferences(Reference... references)

      References of all resources that are addressed in the predicate. The API generates this array from the predicate.

      Parameters:
      references - value to be set
      Returns:
      Builder
    • plusReferences

      public CartDiscountBuilder plusReferences(Function<ReferenceBuilder,Builder<? extends Reference>> builder)

      References of all resources that are addressed in the predicate. The API generates this array from the predicate.

      Parameters:
      builder - function to build the references value
      Returns:
      Builder
    • withReferences

      public CartDiscountBuilder withReferences(Function<ReferenceBuilder,Builder<? extends Reference>> builder)

      References of all resources that are addressed in the predicate. The API generates this array from the predicate.

      Parameters:
      builder - function to build the references value
      Returns:
      Builder
    • stackingMode

      public CartDiscountBuilder stackingMode(StackingMode stackingMode)

      Indicates whether the application of the CartDiscount causes other discounts to be ignored.

      Parameters:
      stackingMode - value to be set
      Returns:
      Builder
    • custom

      Custom Fields of the CartDiscount.

      Parameters:
      builder - function to build the custom value
      Returns:
      Builder
    • withCustom

      Custom Fields of the CartDiscount.

      Parameters:
      builder - function to build the custom value
      Returns:
      Builder
    • custom

      public CartDiscountBuilder custom(@Nullable CustomFields custom)

      Custom Fields of the CartDiscount.

      Parameters:
      custom - value to be set
      Returns:
      Builder
    • getId

      public String getId()

      Unique identifier of the CartDiscount.

      Returns:
      id
    • getVersion

      public Long getVersion()

      Current version of the CartDiscount.

      Returns:
      version
    • getCreatedAt

      public ZonedDateTime getCreatedAt()

      Date and time (UTC) the CartDiscount was initially created.

      Returns:
      createdAt
    • getLastModifiedAt

      public ZonedDateTime getLastModifiedAt()

      Date and time (UTC) the CartDiscount was last updated.

      Returns:
      lastModifiedAt
    • getLastModifiedBy

      @Nullable public LastModifiedBy getLastModifiedBy()

      IDs and references that last modified the CartDiscount.

      Returns:
      lastModifiedBy
    • getCreatedBy

      @Nullable public CreatedBy getCreatedBy()

      IDs and references that created the CartDiscount.

      Returns:
      createdBy
    • getName

      public LocalizedString getName()

      Name of the CartDiscount.

      Returns:
      name
    • getKey

      @Nullable public String getKey()

      User-defined unique identifier of the CartDiscount.

      Returns:
      key
    • getDescription

      @Nullable public LocalizedString getDescription()

      Description of the CartDiscount.

      Returns:
      description
    • getValue

      public CartDiscountValue getValue()

      Effect of the CartDiscount on the target.

      Returns:
      value
    • getCartPredicate

      public String getCartPredicate()

      Valid Cart Predicate.

      Returns:
      cartPredicate
    • getTarget

      @Nullable public CartDiscountTarget getTarget()

      Segment of the Cart that is discounted.

      Empty, if the value is giftLineItem.

      Returns:
      target
    • getSortOrder

      public String getSortOrder()

      Value between 0 and 1. All matching CartDiscounts are applied to a Cart in the order defined by this field. A Discount with a higher sortOrder is prioritized. The sort order is unambiguous among all CartDiscounts.

      Returns:
      sortOrder
    • getStores

      public List<StoreKeyReference> getStores()
      • If a value exists, the Cart Discount applies on Carts having a Store matching any Store defined for this field.
      • If empty, the Cart Discount applies on all Carts, irrespective of a Store.
      Returns:
      stores
    • getIsActive

      public Boolean getIsActive()

      Indicates if the CartDiscount is active and can be applied to the Cart.

      Returns:
      isActive
    • getValidFrom

      @Nullable public ZonedDateTime getValidFrom()

      Date and time (UTC) from which the Discount is effective.

      Returns:
      validFrom
    • getValidUntil

      @Nullable public ZonedDateTime getValidUntil()

      Date and time (UTC) until which the Discount is effective.

      Returns:
      validUntil
    • getRequiresDiscountCode

      public Boolean getRequiresDiscountCode()

      Indicates if the Discount is used in connection with a DiscountCode.

      Returns:
      requiresDiscountCode
    • getReferences

      public List<Reference> getReferences()

      References of all resources that are addressed in the predicate. The API generates this array from the predicate.

      Returns:
      references
    • getStackingMode

      public StackingMode getStackingMode()

      Indicates whether the application of the CartDiscount causes other discounts to be ignored.

      Returns:
      stackingMode
    • getCustom

      @Nullable public CustomFields getCustom()

      Custom Fields of the CartDiscount.

      Returns:
      custom
    • build

      public CartDiscount build()
      builds CartDiscount with checking for non-null required values
      Specified by:
      build in interface Builder<CartDiscount>
      Returns:
      CartDiscount
    • buildUnchecked

      public CartDiscount buildUnchecked()
      builds CartDiscount without checking for non-null required values
      Returns:
      CartDiscount
    • of

      public static CartDiscountBuilder of()
      factory method for an instance of CartDiscountBuilder
      Returns:
      builder
    • of

      public static CartDiscountBuilder of(CartDiscount template)
      create builder for CartDiscount instance
      Parameters:
      template - instance with prefilled values for the builder
      Returns:
      builder