Class ProductVariantBuilder
java.lang.Object
com.commercetools.ml.models.common.ProductVariantBuilder
- All Implemented Interfaces:
Builder<ProductVariant>
ProductVariantBuilder
Example to create an instance using the builder pattern
Example to create an instance using the builder pattern
ProductVariant productVariant = ProductVariant.builder()
.product(productBuilder -> productBuilder)
.staged(true)
.variantId(0.3)
.build()
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionbuild()
builds ProductVariant with checking for non-null required valuesbuilds ProductVariant without checking for non-null required valuesThe product that contains this variant.The state of the product variant.The id of the product variant.static ProductVariantBuilder
of()
factory method for an instance of ProductVariantBuilderstatic ProductVariantBuilder
of
(ProductVariant template) create builder for ProductVariant instanceproduct
(ProductReference product) The product that contains this variant.The product that contains this variant.The state of the product variant.The id of the product variant.The product that contains this variant.
-
Constructor Details
-
ProductVariantBuilder
public ProductVariantBuilder()
-
-
Method Details
-
product
public ProductVariantBuilder product(Function<ProductReferenceBuilder, ProductReferenceBuilder> builder) The product that contains this variant.
- Parameters:
builder
- function to build the product value- Returns:
- Builder
-
withProduct
public ProductVariantBuilder withProduct(Function<ProductReferenceBuilder, ProductReference> builder) The product that contains this variant.
- Parameters:
builder
- function to build the product value- Returns:
- Builder
-
product
The product that contains this variant.
- Parameters:
product
- value to be set- Returns:
- Builder
-
staged
The state of the product variant.
- Parameters:
staged
- value to be set- Returns:
- Builder
-
variantId
The id of the product variant.
- Parameters:
variantId
- value to be set- Returns:
- Builder
-
getProduct
The product that contains this variant.
- Returns:
- product
-
getStaged
The state of the product variant.
- Returns:
- staged
-
getVariantId
The id of the product variant.
- Returns:
- variantId
-
build
builds ProductVariant with checking for non-null required values- Specified by:
build
in interfaceBuilder<ProductVariant>
- Returns:
- ProductVariant
-
buildUnchecked
builds ProductVariant without checking for non-null required values- Returns:
- ProductVariant
-
of
factory method for an instance of ProductVariantBuilder- Returns:
- builder
-
of
create builder for ProductVariant instance- Parameters:
template
- instance with prefilled values for the builder- Returns:
- builder
-