001
002package com.commercetools.api.models.error;
003
004import java.time.*;
005import java.util.*;
006import java.util.function.Function;
007import java.util.stream.Collectors;
008
009import javax.annotation.Nullable;
010import javax.validation.Valid;
011import javax.validation.constraints.NotNull;
012
013import com.commercetools.api.models.common.PriceDraft;
014import com.commercetools.api.models.product.Attribute;
015import com.fasterxml.jackson.annotation.*;
016import com.fasterxml.jackson.databind.annotation.*;
017
018import io.vrap.rmf.base.client.utils.Generated;
019
020/**
021 * VariantValues
022 *
023 * <hr>
024 * Example to create an instance using the builder pattern
025 * <div class=code-example>
026 * <pre><code class='java'>
027 *     VariantValues variantValues = VariantValues.builder()
028 *             .plusPrices(pricesBuilder -> pricesBuilder)
029 *             .plusAttributes(attributesBuilder -> attributesBuilder)
030 *             .build()
031 * </code></pre>
032 * </div>
033 */
034@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen")
035@JsonDeserialize(as = VariantValuesImpl.class)
036public interface VariantValues {
037
038    /**
039     *  <p>SKU of the ProductVariant.</p>
040     * @return sku
041     */
042
043    @JsonProperty("sku")
044    public String getSku();
045
046    /**
047     *  <p>Embedded Prices of the ProductVariant.</p>
048     * @return prices
049     */
050    @NotNull
051    @Valid
052    @JsonProperty("prices")
053    public List<PriceDraft> getPrices();
054
055    /**
056     *  <p>Attributes of the ProductVariant.</p>
057     * @return attributes
058     */
059    @NotNull
060    @Valid
061    @JsonProperty("attributes")
062    public List<Attribute> getAttributes();
063
064    /**
065     *  <p>SKU of the ProductVariant.</p>
066     * @param sku value to be set
067     */
068
069    public void setSku(final String sku);
070
071    /**
072     *  <p>Embedded Prices of the ProductVariant.</p>
073     * @param prices values to be set
074     */
075
076    @JsonIgnore
077    public void setPrices(final PriceDraft... prices);
078
079    /**
080     *  <p>Embedded Prices of the ProductVariant.</p>
081     * @param prices values to be set
082     */
083
084    public void setPrices(final List<PriceDraft> prices);
085
086    /**
087     *  <p>Attributes of the ProductVariant.</p>
088     * @param attributes values to be set
089     */
090
091    @JsonIgnore
092    public void setAttributes(final Attribute... attributes);
093
094    /**
095     *  <p>Attributes of the ProductVariant.</p>
096     * @param attributes values to be set
097     */
098
099    public void setAttributes(final List<Attribute> attributes);
100
101    /**
102     * factory method
103     * @return instance of VariantValues
104     */
105    public static VariantValues of() {
106        return new VariantValuesImpl();
107    }
108
109    /**
110     * factory method to create a shallow copy VariantValues
111     * @param template instance to be copied
112     * @return copy instance
113     */
114    public static VariantValues of(final VariantValues template) {
115        VariantValuesImpl instance = new VariantValuesImpl();
116        instance.setSku(template.getSku());
117        instance.setPrices(template.getPrices());
118        instance.setAttributes(template.getAttributes());
119        return instance;
120    }
121
122    /**
123     * factory method to create a deep copy of VariantValues
124     * @param template instance to be copied
125     * @return copy instance
126     */
127    @Nullable
128    public static VariantValues deepCopy(@Nullable final VariantValues template) {
129        if (template == null) {
130            return null;
131        }
132        VariantValuesImpl instance = new VariantValuesImpl();
133        instance.setSku(template.getSku());
134        instance.setPrices(Optional.ofNullable(template.getPrices())
135                .map(t -> t.stream()
136                        .map(com.commercetools.api.models.common.PriceDraft::deepCopy)
137                        .collect(Collectors.toList()))
138                .orElse(null));
139        instance.setAttributes(Optional.ofNullable(template.getAttributes())
140                .map(t -> t.stream()
141                        .map(com.commercetools.api.models.product.Attribute::deepCopy)
142                        .collect(Collectors.toList()))
143                .orElse(null));
144        return instance;
145    }
146
147    /**
148     * builder factory method for VariantValues
149     * @return builder
150     */
151    public static VariantValuesBuilder builder() {
152        return VariantValuesBuilder.of();
153    }
154
155    /**
156     * create builder for VariantValues instance
157     * @param template instance with prefilled values for the builder
158     * @return builder
159     */
160    public static VariantValuesBuilder builder(final VariantValues template) {
161        return VariantValuesBuilder.of(template);
162    }
163
164    /**
165     * accessor map function
166     * @param <T> mapped type
167     * @param helper function to map the object
168     * @return mapped value
169     */
170    default <T> T withVariantValues(Function<VariantValues, T> helper) {
171        return helper.apply(this);
172    }
173
174    /**
175     * gives a TypeReference for usage with Jackson DataBind
176     * @return TypeReference
177     */
178    public static com.fasterxml.jackson.core.type.TypeReference<VariantValues> typeReference() {
179        return new com.fasterxml.jackson.core.type.TypeReference<VariantValues>() {
180            @Override
181            public String toString() {
182                return "TypeReference<VariantValues>";
183            }
184        };
185    }
186}