Class ProductBuilder

java.lang.Object
com.commercetools.api.models.product.ProductBuilder
All Implemented Interfaces:
Builder<Product>

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

     Product product = Product.builder()
             .id("{id}")
             .version(0.3)
             .createdAt(ZonedDateTime.parse("2022-01-01T12:00:00.301Z"))
             .lastModifiedAt(ZonedDateTime.parse("2022-01-01T12:00:00.301Z"))
             .productType(productTypeBuilder -> productTypeBuilder)
             .masterData(masterDataBuilder -> masterDataBuilder)
             .build()
 
  • Constructor Details

    • ProductBuilder

      public ProductBuilder()
  • Method Details

    • id

      public ProductBuilder id(String id)

      Unique identifier of the Product.

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

      public ProductBuilder version(Long version)

      Current version of the Product.

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

      public ProductBuilder createdAt(ZonedDateTime createdAt)

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

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

      public ProductBuilder lastModifiedAt(ZonedDateTime lastModifiedAt)

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

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

      IDs and references that last modified the Product.

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

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

      IDs and references that last modified the Product.

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

      public ProductBuilder lastModifiedBy(@Nullable LastModifiedBy lastModifiedBy)

      IDs and references that last modified the Product.

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

      IDs and references that created the Product.

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

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

      IDs and references that created the Product.

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

      public ProductBuilder createdBy(@Nullable CreatedBy createdBy)

      IDs and references that created the Product.

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

      public ProductBuilder key(@Nullable String key)

      User-defined unique identifier of the Product.

      This is different from the key of a ProductVariant.

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

      The Product Type defining the Attributes of the Product. Cannot be changed.

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

      The Product Type defining the Attributes of the Product. Cannot be changed.

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

      public ProductBuilder productType(ProductTypeReference productType)

      The Product Type defining the Attributes of the Product. Cannot be changed.

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

      Contains the current and the staged representation of the product information.

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

      Contains the current and the staged representation of the product information.

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

      public ProductBuilder masterData(ProductCatalogData masterData)

      Contains the current and the staged representation of the product information.

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

      The TaxCategory of the Product.

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

      The TaxCategory of the Product.

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

      public ProductBuilder taxCategory(@Nullable TaxCategoryReference taxCategory)

      The TaxCategory of the Product.

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

      State of the Product.

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

      State of the Product.

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

      public ProductBuilder state(@Nullable StateReference state)

      State of the Product.

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

      Review statistics of the Product.

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

      public ProductBuilder withReviewRatingStatistics(Function<ReviewRatingStatisticsBuilder,ReviewRatingStatistics> builder)

      Review statistics of the Product.

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

      public ProductBuilder reviewRatingStatistics(@Nullable ReviewRatingStatistics reviewRatingStatistics)

      Review statistics of the Product.

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

      public ProductBuilder priceMode(@Nullable ProductPriceModeEnum priceMode)

      Type of Price to be used when looking up a price for the Product.

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

      public ProductBuilder warnings(@Nullable WarningObject... warnings)

      Warnings about processing of a request. Appears in response to requests with response status code 202 Accepted.

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

      public ProductBuilder warnings(@Nullable List<WarningObject> warnings)

      Warnings about processing of a request. Appears in response to requests with response status code 202 Accepted.

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

      public ProductBuilder plusWarnings(@Nullable WarningObject... warnings)

      Warnings about processing of a request. Appears in response to requests with response status code 202 Accepted.

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

      public ProductBuilder plusWarnings(Function<WarningObjectBuilder,Builder<? extends WarningObject>> builder)

      Warnings about processing of a request. Appears in response to requests with response status code 202 Accepted.

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

      public ProductBuilder withWarnings(Function<WarningObjectBuilder,Builder<? extends WarningObject>> builder)

      Warnings about processing of a request. Appears in response to requests with response status code 202 Accepted.

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

      public String getId()

      Unique identifier of the Product.

      Returns:
      id
    • getVersion

      public Long getVersion()

      Current version of the Product.

      Returns:
      version
    • getCreatedAt

      public ZonedDateTime getCreatedAt()

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

      Returns:
      createdAt
    • getLastModifiedAt

      public ZonedDateTime getLastModifiedAt()

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

      Returns:
      lastModifiedAt
    • getLastModifiedBy

      @Nullable public LastModifiedBy getLastModifiedBy()

      IDs and references that last modified the Product.

      Returns:
      lastModifiedBy
    • getCreatedBy

      @Nullable public CreatedBy getCreatedBy()

      IDs and references that created the Product.

      Returns:
      createdBy
    • getKey

      @Nullable public String getKey()

      User-defined unique identifier of the Product.

      This is different from the key of a ProductVariant.

      Returns:
      key
    • getProductType

      public ProductTypeReference getProductType()

      The Product Type defining the Attributes of the Product. Cannot be changed.

      Returns:
      productType
    • getMasterData

      public ProductCatalogData getMasterData()

      Contains the current and the staged representation of the product information.

      Returns:
      masterData
    • getTaxCategory

      @Nullable public TaxCategoryReference getTaxCategory()

      The TaxCategory of the Product.

      Returns:
      taxCategory
    • getState

      @Nullable public StateReference getState()

      State of the Product.

      Returns:
      state
    • getReviewRatingStatistics

      @Nullable public ReviewRatingStatistics getReviewRatingStatistics()

      Review statistics of the Product.

      Returns:
      reviewRatingStatistics
    • getPriceMode

      @Nullable public ProductPriceModeEnum getPriceMode()

      Type of Price to be used when looking up a price for the Product.

      Returns:
      priceMode
    • getWarnings

      @Nullable public List<WarningObject> getWarnings()

      Warnings about processing of a request. Appears in response to requests with response status code 202 Accepted.

      Returns:
      warnings
    • build

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

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

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

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