001
002package com.commercetools.ml.models.common;
003
004import java.util.*;
005import java.util.function.Function;
006
007import io.vrap.rmf.base.client.Builder;
008import io.vrap.rmf.base.client.utils.Generated;
009
010/**
011 * ProductVariantBuilder
012 * <hr>
013 * Example to create an instance using the builder pattern
014 * <div class=code-example>
015 * <pre><code class='java'>
016 *     ProductVariant productVariant = ProductVariant.builder()
017 *             .product(productBuilder -> productBuilder)
018 *             .staged(true)
019 *             .variantId(0.3)
020 *             .build()
021 * </code></pre>
022 * </div>
023 */
024@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen")
025public class ProductVariantBuilder implements Builder<ProductVariant> {
026
027    private com.commercetools.ml.models.common.ProductReference product;
028
029    private Boolean staged;
030
031    private Integer variantId;
032
033    /**
034     *  <p>The product that contains this variant.</p>
035     * @param builder function to build the product value
036     * @return Builder
037     */
038
039    public ProductVariantBuilder product(
040            Function<com.commercetools.ml.models.common.ProductReferenceBuilder, com.commercetools.ml.models.common.ProductReferenceBuilder> builder) {
041        this.product = builder.apply(com.commercetools.ml.models.common.ProductReferenceBuilder.of()).build();
042        return this;
043    }
044
045    /**
046     *  <p>The product that contains this variant.</p>
047     * @param builder function to build the product value
048     * @return Builder
049     */
050
051    public ProductVariantBuilder withProduct(
052            Function<com.commercetools.ml.models.common.ProductReferenceBuilder, com.commercetools.ml.models.common.ProductReference> builder) {
053        this.product = builder.apply(com.commercetools.ml.models.common.ProductReferenceBuilder.of());
054        return this;
055    }
056
057    /**
058     *  <p>The product that contains this variant.</p>
059     * @param product value to be set
060     * @return Builder
061     */
062
063    public ProductVariantBuilder product(final com.commercetools.ml.models.common.ProductReference product) {
064        this.product = product;
065        return this;
066    }
067
068    /**
069     *  <p>The state of the product variant.</p>
070     * @param staged value to be set
071     * @return Builder
072     */
073
074    public ProductVariantBuilder staged(final Boolean staged) {
075        this.staged = staged;
076        return this;
077    }
078
079    /**
080     *  <p>The id of the product variant.</p>
081     * @param variantId value to be set
082     * @return Builder
083     */
084
085    public ProductVariantBuilder variantId(final Integer variantId) {
086        this.variantId = variantId;
087        return this;
088    }
089
090    /**
091     *  <p>The product that contains this variant.</p>
092     * @return product
093     */
094
095    public com.commercetools.ml.models.common.ProductReference getProduct() {
096        return this.product;
097    }
098
099    /**
100     *  <p>The state of the product variant.</p>
101     * @return staged
102     */
103
104    public Boolean getStaged() {
105        return this.staged;
106    }
107
108    /**
109     *  <p>The id of the product variant.</p>
110     * @return variantId
111     */
112
113    public Integer getVariantId() {
114        return this.variantId;
115    }
116
117    /**
118     * builds ProductVariant with checking for non-null required values
119     * @return ProductVariant
120     */
121    public ProductVariant build() {
122        Objects.requireNonNull(product, ProductVariant.class + ": product is missing");
123        Objects.requireNonNull(staged, ProductVariant.class + ": staged is missing");
124        Objects.requireNonNull(variantId, ProductVariant.class + ": variantId is missing");
125        return new ProductVariantImpl(product, staged, variantId);
126    }
127
128    /**
129     * builds ProductVariant without checking for non-null required values
130     * @return ProductVariant
131     */
132    public ProductVariant buildUnchecked() {
133        return new ProductVariantImpl(product, staged, variantId);
134    }
135
136    /**
137     * factory method for an instance of ProductVariantBuilder
138     * @return builder
139     */
140    public static ProductVariantBuilder of() {
141        return new ProductVariantBuilder();
142    }
143
144    /**
145     * create builder for ProductVariant instance
146     * @param template instance with prefilled values for the builder
147     * @return builder
148     */
149    public static ProductVariantBuilder of(final ProductVariant template) {
150        ProductVariantBuilder builder = new ProductVariantBuilder();
151        builder.product = template.getProduct();
152        builder.staged = template.getStaged();
153        builder.variantId = template.getVariantId();
154        return builder;
155    }
156
157}