Class ProductDiscountBuilder

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

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

     ProductDiscount productDiscount = ProductDiscount.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)
             .predicate("{predicate}")
             .sortOrder("{sortOrder}")
             .isActive(true)
             .plusReferences(referencesBuilder -> referencesBuilder)
             .build()
 
  • Constructor Details

    • ProductDiscountBuilder

      public ProductDiscountBuilder()
  • Method Details

    • id

      Unique identifier of the ProductDiscount.

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

      public ProductDiscountBuilder version(Long version)

      Current version of the ProductDiscount.

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

      public ProductDiscountBuilder createdAt(ZonedDateTime createdAt)

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

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

      public ProductDiscountBuilder lastModifiedAt(ZonedDateTime lastModifiedAt)

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

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

      IDs and references that last modified the ProductDiscount.

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

      IDs and references that last modified the ProductDiscount.

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

      public ProductDiscountBuilder lastModifiedBy(@Nullable LastModifiedBy lastModifiedBy)

      IDs and references that last modified the ProductDiscount.

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

      IDs and references that created the ProductDiscount.

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

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

      IDs and references that created the ProductDiscount.

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

      public ProductDiscountBuilder createdBy(@Nullable CreatedBy createdBy)

      IDs and references that created the ProductDiscount.

      Parameters:
      createdBy - value to be set
      Returns:
      Builder
    • 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 of 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 ProductDiscountBuilder 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 ProductDiscountBuilder predicate(String predicate)

      Valid ProductDiscount predicate.

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

      public ProductDiscountBuilder sortOrder(String sortOrder)

      Unique decimal value between 0 and 1 (stored as String literal) defining the order of Product Discounts to apply in case more than one is applicable and active. A Product Discount with a higher value is prioritized.

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

      public ProductDiscountBuilder isActive(Boolean isActive)

      If true the Product Discount is applied to Products matching the predicate.

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

      public ProductDiscountBuilder references(Reference... references)

      References of all the resources that are addressed in the predicate.

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

      public ProductDiscountBuilder references(List<Reference> references)

      References of all the resources that are addressed in the predicate.

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

      public ProductDiscountBuilder plusReferences(Reference... references)

      References of all the resources that are addressed in the predicate.

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

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

      References of all the resources that are addressed in the predicate.

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

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

      References of all the resources that are addressed in the predicate.

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

      public ProductDiscountBuilder 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 ProductDiscountBuilder 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
    • getId

      public String getId()

      Unique identifier of the ProductDiscount.

      Returns:
      id
    • getVersion

      public Long getVersion()

      Current version of the ProductDiscount.

      Returns:
      version
    • getCreatedAt

      public ZonedDateTime getCreatedAt()

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

      Returns:
      createdAt
    • getLastModifiedAt

      public ZonedDateTime getLastModifiedAt()

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

      Returns:
      lastModifiedAt
    • getLastModifiedBy

      @Nullable public LastModifiedBy getLastModifiedBy()

      IDs and references that last modified the ProductDiscount.

      Returns:
      lastModifiedBy
    • getCreatedBy

      @Nullable public CreatedBy getCreatedBy()

      IDs and references that created the ProductDiscount.

      Returns:
      createdBy
    • getName

      public LocalizedString getName()

      Name of the ProductDiscount.

      Returns:
      name
    • getKey

      @Nullable public String getKey()

      User-defined unique identifier of the ProductDiscount.

      Returns:
      key
    • getDescription

      @Nullable public LocalizedString getDescription()

      Description of the ProductDiscount.

      Returns:
      description
    • getValue

      public ProductDiscountValue getValue()

      Type of Discount and its corresponding value.

      Returns:
      value
    • getPredicate

      public String getPredicate()

      Valid ProductDiscount predicate.

      Returns:
      predicate
    • getSortOrder

      public String getSortOrder()

      Unique decimal value between 0 and 1 (stored as String literal) defining the order of Product Discounts to apply in case more than one is applicable and active. A Product Discount with a higher value is prioritized.

      Returns:
      sortOrder
    • getIsActive

      public Boolean getIsActive()

      If true the Product Discount is applied to Products matching the predicate.

      Returns:
      isActive
    • getReferences

      public List<Reference> getReferences()

      References of all the resources that are addressed in the predicate.

      Returns:
      references
    • 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 ProductDiscount build()
      builds ProductDiscount with checking for non-null required values
      Specified by:
      build in interface Builder<ProductDiscount>
      Returns:
      ProductDiscount
    • buildUnchecked

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

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

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