Class DiscountCodeBuilder

java.lang.Object
com.commercetools.api.models.discount_code.DiscountCodeBuilder
All Implemented Interfaces:
Builder<DiscountCode>

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

     DiscountCode discountCode = DiscountCode.builder()
             .id("{id}")
             .version(0.3)
             .createdAt(ZonedDateTime.parse("2022-01-01T12:00:00.301Z"))
             .lastModifiedAt(ZonedDateTime.parse("2022-01-01T12:00:00.301Z"))
             .code("{code}")
             .plusCartDiscounts(cartDiscountsBuilder -> cartDiscountsBuilder)
             .isActive(true)
             .plusReferences(referencesBuilder -> referencesBuilder)
             .plusGroups(groupsBuilder -> groupsBuilder)
             .build()
 
  • Constructor Details

    • DiscountCodeBuilder

      public DiscountCodeBuilder()
  • Method Details

    • id

      public DiscountCodeBuilder id(String id)

      Unique identifier of the DiscountCode.

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

      public DiscountCodeBuilder version(Long version)

      Current version of the DiscountCode.

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

      public DiscountCodeBuilder createdAt(ZonedDateTime createdAt)

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

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

      public DiscountCodeBuilder lastModifiedAt(ZonedDateTime lastModifiedAt)

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

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

      User-defined unique identifier of the DiscountCode.

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

      IDs and references that last modified the DiscountCode.

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

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

      IDs and references that last modified the DiscountCode.

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

      public DiscountCodeBuilder lastModifiedBy(@Nullable LastModifiedBy lastModifiedBy)

      IDs and references that last modified the DiscountCode.

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

      IDs and references that created the DiscountCode.

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

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

      IDs and references that created the DiscountCode.

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

      public DiscountCodeBuilder createdBy(@Nullable CreatedBy createdBy)

      IDs and references that created the DiscountCode.

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

      Name of the DiscountCode.

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

      Name of the DiscountCode.

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

      Name of the DiscountCode.

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

      Description of the DiscountCode.

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

      Description of the DiscountCode.

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

      public DiscountCodeBuilder description(@Nullable LocalizedString description)

      Description of the DiscountCode.

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

      public DiscountCodeBuilder code(String code)

      User-defined unique identifier of the DiscountCode added to the Cart to apply the related CartDiscounts.

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

      public DiscountCodeBuilder cartDiscounts(CartDiscountReference... cartDiscounts)

      Reference to CartDiscounts that can be applied to the Cart once the DiscountCode is applied.

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

      public DiscountCodeBuilder cartDiscounts(List<CartDiscountReference> cartDiscounts)

      Reference to CartDiscounts that can be applied to the Cart once the DiscountCode is applied.

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

      public DiscountCodeBuilder plusCartDiscounts(CartDiscountReference... cartDiscounts)

      Reference to CartDiscounts that can be applied to the Cart once the DiscountCode is applied.

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

      Reference to CartDiscounts that can be applied to the Cart once the DiscountCode is applied.

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

      Reference to CartDiscounts that can be applied to the Cart once the DiscountCode is applied.

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

      Reference to CartDiscounts that can be applied to the Cart once the DiscountCode is applied.

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

      Reference to CartDiscounts that can be applied to the Cart once the DiscountCode is applied.

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

      public DiscountCodeBuilder cartPredicate(@Nullable String cartPredicate)

      DiscountCode can only be applied to Carts that match this predicate.

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

      public DiscountCodeBuilder isActive(Boolean isActive)

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

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

      public DiscountCodeBuilder references(Reference... references)

      Array generated from the Cart predicate. It contains the references of all the resources that are addressed in the predicate.

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

      public DiscountCodeBuilder references(List<Reference> references)

      Array generated from the Cart predicate. It contains the references of all the resources that are addressed in the predicate.

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

      public DiscountCodeBuilder plusReferences(Reference... references)

      Array generated from the Cart predicate. It contains the references of all the resources that are addressed in the predicate.

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

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

      Array generated from the Cart predicate. It contains the references of all the resources that are addressed in the predicate.

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

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

      Array generated from the Cart predicate. It contains the references of all the resources that are addressed in the predicate.

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

      public DiscountCodeBuilder maxApplications(@Nullable Long maxApplications)

      Number of times the DiscountCode can be applied. DiscountCode application is counted at the time of Order creation or edit. However, Order cancellation or deletion does not decrement the count.

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

      public DiscountCodeBuilder maxApplicationsPerCustomer(@Nullable Long maxApplicationsPerCustomer)

      Number of times the DiscountCode can be applied per Customer (anonymous Carts are not supported). DiscountCode application is counted at the time of Order creation or edit. However, Order cancellation or deletion does not decrement the count.

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

      Custom Fields of the DiscountCode.

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

      Custom Fields of the DiscountCode.

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

      public DiscountCodeBuilder custom(@Nullable CustomFields custom)

      Custom Fields of the DiscountCode.

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

      public DiscountCodeBuilder groups(String... groups)

      Groups to which the DiscountCode belongs to.

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

      public DiscountCodeBuilder groups(List<String> groups)

      Groups to which the DiscountCode belongs to.

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

      public DiscountCodeBuilder plusGroups(String... groups)

      Groups to which the DiscountCode belongs to.

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

      public DiscountCodeBuilder validFrom(@Nullable ZonedDateTime validFrom)

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

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

      public DiscountCodeBuilder validUntil(@Nullable ZonedDateTime validUntil)

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

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

      public DiscountCodeBuilder applicationVersion(@Nullable Long applicationVersion)

      Used and managed by the API and must not be used in customer logic. The value can change at any time due to internal and external factors.

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

      public String getId()

      Unique identifier of the DiscountCode.

      Returns:
      id
    • getVersion

      public Long getVersion()

      Current version of the DiscountCode.

      Returns:
      version
    • getCreatedAt

      public ZonedDateTime getCreatedAt()

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

      Returns:
      createdAt
    • getLastModifiedAt

      public ZonedDateTime getLastModifiedAt()

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

      Returns:
      lastModifiedAt
    • getKey

      @Nullable public String getKey()

      User-defined unique identifier of the DiscountCode.

      Returns:
      key
    • getLastModifiedBy

      @Nullable public LastModifiedBy getLastModifiedBy()

      IDs and references that last modified the DiscountCode.

      Returns:
      lastModifiedBy
    • getCreatedBy

      @Nullable public CreatedBy getCreatedBy()

      IDs and references that created the DiscountCode.

      Returns:
      createdBy
    • getName

      @Nullable public LocalizedString getName()

      Name of the DiscountCode.

      Returns:
      name
    • getDescription

      @Nullable public LocalizedString getDescription()

      Description of the DiscountCode.

      Returns:
      description
    • getCode

      public String getCode()

      User-defined unique identifier of the DiscountCode added to the Cart to apply the related CartDiscounts.

      Returns:
      code
    • getCartDiscounts

      public List<CartDiscountReference> getCartDiscounts()

      Reference to CartDiscounts that can be applied to the Cart once the DiscountCode is applied.

      Returns:
      cartDiscounts
    • getCartPredicate

      @Nullable public String getCartPredicate()

      DiscountCode can only be applied to Carts that match this predicate.

      Returns:
      cartPredicate
    • getIsActive

      public Boolean getIsActive()

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

      Returns:
      isActive
    • getReferences

      public List<Reference> getReferences()

      Array generated from the Cart predicate. It contains the references of all the resources that are addressed in the predicate.

      Returns:
      references
    • getMaxApplications

      @Nullable public Long getMaxApplications()

      Number of times the DiscountCode can be applied. DiscountCode application is counted at the time of Order creation or edit. However, Order cancellation or deletion does not decrement the count.

      Returns:
      maxApplications
    • getMaxApplicationsPerCustomer

      @Nullable public Long getMaxApplicationsPerCustomer()

      Number of times the DiscountCode can be applied per Customer (anonymous Carts are not supported). DiscountCode application is counted at the time of Order creation or edit. However, Order cancellation or deletion does not decrement the count.

      Returns:
      maxApplicationsPerCustomer
    • getCustom

      @Nullable public CustomFields getCustom()

      Custom Fields of the DiscountCode.

      Returns:
      custom
    • getGroups

      public List<String> getGroups()

      Groups to which the DiscountCode belongs to.

      Returns:
      groups
    • getValidFrom

      @Nullable public ZonedDateTime getValidFrom()

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

      Returns:
      validFrom
    • getValidUntil

      @Nullable public ZonedDateTime getValidUntil()

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

      Returns:
      validUntil
    • getApplicationVersion

      @Nullable public Long getApplicationVersion()

      Used and managed by the API and must not be used in customer logic. The value can change at any time due to internal and external factors.

      Returns:
      applicationVersion
    • build

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

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

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

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