Class ProductVariantBuilder

java.lang.Object
com.commercetools.ml.models.common.ProductVariantBuilder
All Implemented Interfaces:
Builder<ProductVariant>

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

     ProductVariant productVariant = ProductVariant.builder()
             .product(productBuilder -> productBuilder)
             .staged(true)
             .variantId(0.3)
             .build()
 
  • Constructor Details

    • ProductVariantBuilder

      public ProductVariantBuilder()
  • Method Details

    • product

      The product that contains this variant.

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

      The product that contains this variant.

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

      public ProductVariantBuilder product(ProductReference product)

      The product that contains this variant.

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

      public ProductVariantBuilder staged(Boolean staged)

      The state of the product variant.

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

      public ProductVariantBuilder variantId(Integer variantId)

      The id of the product variant.

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

      public ProductReference getProduct()

      The product that contains this variant.

      Returns:
      product
    • getStaged

      public Boolean getStaged()

      The state of the product variant.

      Returns:
      staged
    • getVariantId

      public Integer getVariantId()

      The id of the product variant.

      Returns:
      variantId
    • build

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

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

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

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