Class ProductDiscountDraftBuilder

java.lang.Object
com.commercetools.api.models.product_discount.ProductDiscountDraftBuilder
All Implemented Interfaces:
Builder<ProductDiscountDraft>

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

     ProductDiscountDraft productDiscountDraft = ProductDiscountDraft.builder()
             .name(nameBuilder -> nameBuilder)
             .value(valueBuilder -> valueBuilder)
             .predicate("{predicate}")
             .sortOrder("{sortOrder}")
             .isActive(true)
             .build()
 
  • Constructor Details

    • ProductDiscountDraftBuilder

      public ProductDiscountDraftBuilder()
  • Method Details

    • name

      Name of the ProductDiscount.

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

      Name of the ProductDiscount.

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

      Name of the ProductDiscount.

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

      User-defined unique identifier for the ProductDiscount.

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

      Description of the ProductDiscount.

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

      Description of the ProductDiscount.

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

      public ProductDiscountDraftBuilder description(@Nullable LocalizedString description)

      Description of the ProductDiscount.

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

      Type of Discount and its corresponding value.

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

      Type of Discount and its corresponding value.

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

      public ProductDiscountDraftBuilder predicate(String predicate)

      Valid ProductDiscount predicate.

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

      public ProductDiscountDraftBuilder sortOrder(String sortOrder)

      Decimal value between 0 and 1 (passed as String literal) that defines the order of ProductDiscounts to apply in case more than one is applicable and active. A ProductDiscount with a higher sortOrder is prioritized. The value must be unique among all ProductDiscounts in the Project.

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

      public ProductDiscountDraftBuilder isActive(Boolean isActive)

      Set to true to activate the ProductDiscount, set to false to deactivate it (even though the predicate matches).

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

      public ProductDiscountDraftBuilder validFrom(@Nullable ZonedDateTime validFrom)

      Date and time (UTC) from which the Discount is effective. Take Eventual Consistency into account for calculated discount values.

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

      public ProductDiscountDraftBuilder validUntil(@Nullable ZonedDateTime validUntil)

      Date and time (UTC) until which the Discount is effective. Take Eventual Consistency into account for calculated undiscounted values.

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

      public LocalizedString getName()

      Name of the ProductDiscount.

      Returns:
      name
    • getKey

      @Nullable public String getKey()

      User-defined unique identifier for the ProductDiscount.

      Returns:
      key
    • getDescription

      @Nullable public LocalizedString getDescription()

      Description of the ProductDiscount.

      Returns:
      description
    • getValue

      public ProductDiscountValueDraft getValue()

      Type of Discount and its corresponding value.

      Returns:
      value
    • getPredicate

      public String getPredicate()

      Valid ProductDiscount predicate.

      Returns:
      predicate
    • getSortOrder

      public String getSortOrder()

      Decimal value between 0 and 1 (passed as String literal) that defines the order of ProductDiscounts to apply in case more than one is applicable and active. A ProductDiscount with a higher sortOrder is prioritized. The value must be unique among all ProductDiscounts in the Project.

      Returns:
      sortOrder
    • getIsActive

      public Boolean getIsActive()

      Set to true to activate the ProductDiscount, set to false to deactivate it (even though the predicate matches).

      Returns:
      isActive
    • getValidFrom

      @Nullable public ZonedDateTime getValidFrom()

      Date and time (UTC) from which the Discount is effective. Take Eventual Consistency into account for calculated discount values.

      Returns:
      validFrom
    • getValidUntil

      @Nullable public ZonedDateTime getValidUntil()

      Date and time (UTC) until which the Discount is effective. Take Eventual Consistency into account for calculated undiscounted values.

      Returns:
      validUntil
    • build

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

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

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

      create builder for ProductDiscountDraft instance
      Parameters:
      template - instance with prefilled values for the builder
      Returns:
      builder