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     */
036
037    public ProductVariantBuilder product(
038            Function<com.commercetools.ml.models.common.ProductReferenceBuilder, com.commercetools.ml.models.common.ProductReferenceBuilder> builder) {
039        this.product = builder.apply(com.commercetools.ml.models.common.ProductReferenceBuilder.of()).build();
040        return this;
041    }
042
043    /**
044     *  <p>The product that contains this variant.</p>
045     */
046
047    public ProductVariantBuilder product(final com.commercetools.ml.models.common.ProductReference product) {
048        this.product = product;
049        return this;
050    }
051
052    /**
053     *  <p>The state of the product variant.</p>
054     */
055
056    public ProductVariantBuilder staged(final Boolean staged) {
057        this.staged = staged;
058        return this;
059    }
060
061    /**
062     *  <p>The id of the product variant.</p>
063     */
064
065    public ProductVariantBuilder variantId(final Integer variantId) {
066        this.variantId = variantId;
067        return this;
068    }
069
070    public com.commercetools.ml.models.common.ProductReference getProduct() {
071        return this.product;
072    }
073
074    public Boolean getStaged() {
075        return this.staged;
076    }
077
078    public Integer getVariantId() {
079        return this.variantId;
080    }
081
082    public ProductVariant build() {
083        Objects.requireNonNull(product, ProductVariant.class + ": product is missing");
084        Objects.requireNonNull(staged, ProductVariant.class + ": staged is missing");
085        Objects.requireNonNull(variantId, ProductVariant.class + ": variantId is missing");
086        return new ProductVariantImpl(product, staged, variantId);
087    }
088
089    /**
090     * builds ProductVariant without checking for non null required values
091     */
092    public ProductVariant buildUnchecked() {
093        return new ProductVariantImpl(product, staged, variantId);
094    }
095
096    public static ProductVariantBuilder of() {
097        return new ProductVariantBuilder();
098    }
099
100    public static ProductVariantBuilder of(final ProductVariant template) {
101        ProductVariantBuilder builder = new ProductVariantBuilder();
102        builder.product = template.getProduct();
103        builder.staged = template.getStaged();
104        builder.variantId = template.getVariantId();
105        return builder;
106    }
107
108}