001
002package com.commercetools.api.models.error;
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 * ProductPresentWithDifferentVariantSelectionErrorBuilder
012 * <hr>
013 * Example to create an instance using the builder pattern
014 * <div class=code-example>
015 * <pre><code class='java'>
016 *     ProductPresentWithDifferentVariantSelectionError productPresentWithDifferentVariantSelectionError = ProductPresentWithDifferentVariantSelectionError.builder()
017 *             .message("{message}")
018 *             .product(productBuilder -> productBuilder)
019 *             .existingVariantSelection(existingVariantSelectionBuilder -> existingVariantSelectionBuilder)
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 ProductPresentWithDifferentVariantSelectionErrorBuilder
026        implements Builder<ProductPresentWithDifferentVariantSelectionError> {
027
028    private String message;
029
030    private Map<String, java.lang.Object> values = new HashMap<>();
031
032    private com.commercetools.api.models.product.ProductReference product;
033
034    private com.commercetools.api.models.product_selection.ProductVariantSelection existingVariantSelection;
035
036    /**
037     *  <p><code>"Product is already present with the following different $variantSelections."</code></p>
038     * @param message value to be set
039     * @return Builder
040     */
041
042    public ProductPresentWithDifferentVariantSelectionErrorBuilder message(final String message) {
043        this.message = message;
044        return this;
045    }
046
047    /**
048     *  <p>Error-specific additional fields.</p>
049     * @param values properties to be set
050     * @return Builder
051     */
052
053    public ProductPresentWithDifferentVariantSelectionErrorBuilder values(final Map<String, java.lang.Object> values) {
054        this.values = values;
055        return this;
056    }
057
058    /**
059     *  <p>Error-specific additional fields.</p>
060     * @param key property name
061     * @param value property value
062     * @return Builder
063     */
064
065    public ProductPresentWithDifferentVariantSelectionErrorBuilder addValue(final String key,
066            final java.lang.Object value) {
067        if (this.values == null) {
068            values = new HashMap<>();
069        }
070        values.put(key, value);
071        return this;
072    }
073
074    /**
075     *  <p>Reference to the Product for which the error was returned.</p>
076     * @param builder function to build the product value
077     * @return Builder
078     */
079
080    public ProductPresentWithDifferentVariantSelectionErrorBuilder product(
081            Function<com.commercetools.api.models.product.ProductReferenceBuilder, com.commercetools.api.models.product.ProductReferenceBuilder> builder) {
082        this.product = builder.apply(com.commercetools.api.models.product.ProductReferenceBuilder.of()).build();
083        return this;
084    }
085
086    /**
087     *  <p>Reference to the Product for which the error was returned.</p>
088     * @param builder function to build the product value
089     * @return Builder
090     */
091
092    public ProductPresentWithDifferentVariantSelectionErrorBuilder withProduct(
093            Function<com.commercetools.api.models.product.ProductReferenceBuilder, com.commercetools.api.models.product.ProductReference> builder) {
094        this.product = builder.apply(com.commercetools.api.models.product.ProductReferenceBuilder.of());
095        return this;
096    }
097
098    /**
099     *  <p>Reference to the Product for which the error was returned.</p>
100     * @param product value to be set
101     * @return Builder
102     */
103
104    public ProductPresentWithDifferentVariantSelectionErrorBuilder product(
105            final com.commercetools.api.models.product.ProductReference product) {
106        this.product = product;
107        return this;
108    }
109
110    /**
111     *  <p>Existing Product Variant Selection or Exclusion for the Product in the Product Selection.</p>
112     * @param existingVariantSelection value to be set
113     * @return Builder
114     */
115
116    public ProductPresentWithDifferentVariantSelectionErrorBuilder existingVariantSelection(
117            final com.commercetools.api.models.product_selection.ProductVariantSelection existingVariantSelection) {
118        this.existingVariantSelection = existingVariantSelection;
119        return this;
120    }
121
122    /**
123     *  <p>Existing Product Variant Selection or Exclusion for the Product in the Product Selection.</p>
124     * @param builder function to build the existingVariantSelection value
125     * @return Builder
126     */
127
128    public ProductPresentWithDifferentVariantSelectionErrorBuilder existingVariantSelection(
129            Function<com.commercetools.api.models.product_selection.ProductVariantSelectionBuilder, Builder<? extends com.commercetools.api.models.product_selection.ProductVariantSelection>> builder) {
130        this.existingVariantSelection = builder
131                .apply(com.commercetools.api.models.product_selection.ProductVariantSelectionBuilder.of())
132                .build();
133        return this;
134    }
135
136    /**
137     *  <p><code>"Product is already present with the following different $variantSelections."</code></p>
138     * @return message
139     */
140
141    public String getMessage() {
142        return this.message;
143    }
144
145    /**
146     *  <p>Error-specific additional fields.</p>
147     * @return pattern properties
148     */
149
150    public Map<String, java.lang.Object> getValues() {
151        return this.values;
152    }
153
154    /**
155     *  <p>Reference to the Product for which the error was returned.</p>
156     * @return product
157     */
158
159    public com.commercetools.api.models.product.ProductReference getProduct() {
160        return this.product;
161    }
162
163    /**
164     *  <p>Existing Product Variant Selection or Exclusion for the Product in the Product Selection.</p>
165     * @return existingVariantSelection
166     */
167
168    public com.commercetools.api.models.product_selection.ProductVariantSelection getExistingVariantSelection() {
169        return this.existingVariantSelection;
170    }
171
172    /**
173     * builds ProductPresentWithDifferentVariantSelectionError with checking for non-null required values
174     * @return ProductPresentWithDifferentVariantSelectionError
175     */
176    public ProductPresentWithDifferentVariantSelectionError build() {
177        Objects.requireNonNull(message,
178            ProductPresentWithDifferentVariantSelectionError.class + ": message is missing");
179        Objects.requireNonNull(product,
180            ProductPresentWithDifferentVariantSelectionError.class + ": product is missing");
181        Objects.requireNonNull(existingVariantSelection,
182            ProductPresentWithDifferentVariantSelectionError.class + ": existingVariantSelection is missing");
183        return new ProductPresentWithDifferentVariantSelectionErrorImpl(message, values, product,
184            existingVariantSelection);
185    }
186
187    /**
188     * builds ProductPresentWithDifferentVariantSelectionError without checking for non-null required values
189     * @return ProductPresentWithDifferentVariantSelectionError
190     */
191    public ProductPresentWithDifferentVariantSelectionError buildUnchecked() {
192        return new ProductPresentWithDifferentVariantSelectionErrorImpl(message, values, product,
193            existingVariantSelection);
194    }
195
196    /**
197     * factory method for an instance of ProductPresentWithDifferentVariantSelectionErrorBuilder
198     * @return builder
199     */
200    public static ProductPresentWithDifferentVariantSelectionErrorBuilder of() {
201        return new ProductPresentWithDifferentVariantSelectionErrorBuilder();
202    }
203
204    /**
205     * create builder for ProductPresentWithDifferentVariantSelectionError instance
206     * @param template instance with prefilled values for the builder
207     * @return builder
208     */
209    public static ProductPresentWithDifferentVariantSelectionErrorBuilder of(
210            final ProductPresentWithDifferentVariantSelectionError template) {
211        ProductPresentWithDifferentVariantSelectionErrorBuilder builder = new ProductPresentWithDifferentVariantSelectionErrorBuilder();
212        builder.message = template.getMessage();
213        builder.values = template.values();
214        builder.product = template.getProduct();
215        builder.existingVariantSelection = template.getExistingVariantSelection();
216        return builder;
217    }
218
219}