001
002package com.commercetools.history.models.change;
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.history.models.common.Price;
014import com.fasterxml.jackson.annotation.*;
015import com.fasterxml.jackson.databind.annotation.*;
016
017import io.vrap.rmf.base.client.utils.Generated;
018
019/**
020 *  <p>Change triggered by the Set Prices update action.</p>
021 *
022 * <hr>
023 * Example to create an instance using the builder pattern
024 * <div class=code-example>
025 * <pre><code class='java'>
026 *     SetPricesChange setPricesChange = SetPricesChange.builder()
027 *             .change("{change}")
028 *             .plusPreviousValue(previousValueBuilder -> previousValueBuilder)
029 *             .plusNextValue(nextValueBuilder -> nextValueBuilder)
030 *             .catalogData("{catalogData}")
031 *             .variant("{variant}")
032 *             .build()
033 * </code></pre>
034 * </div>
035 */
036@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen")
037@JsonDeserialize(as = SetPricesChangeImpl.class)
038public interface SetPricesChange extends Change {
039
040    /**
041     * discriminator value for SetPricesChange
042     */
043    String SET_PRICES_CHANGE = "SetPricesChange";
044
045    /**
046     *
047     * @return type
048     */
049    @NotNull
050    @JsonProperty("type")
051    public String getType();
052
053    /**
054     *
055     * @return change
056     */
057    @NotNull
058    @JsonProperty("change")
059    public String getChange();
060
061    /**
062     *  <p>Value before the change.</p>
063     * @return previousValue
064     */
065    @NotNull
066    @Valid
067    @JsonProperty("previousValue")
068    public List<Price> getPreviousValue();
069
070    /**
071     *  <p>Value after the change.</p>
072     * @return nextValue
073     */
074    @NotNull
075    @Valid
076    @JsonProperty("nextValue")
077    public List<Price> getNextValue();
078
079    /**
080     *  <ul>
081     *   <li><code>staged</code>, if the staged ProductCatalogData was updated.</li>
082     *   <li><code>current</code>, if the current ProductCatalogData was updated.</li>
083     *  </ul>
084     * @return catalogData
085     */
086    @NotNull
087    @JsonProperty("catalogData")
088    public String getCatalogData();
089
090    /**
091     *  <p><code>sku</code> or <code>key</code> of the ProductVariant.</p>
092     * @return variant
093     */
094    @NotNull
095    @JsonProperty("variant")
096    public String getVariant();
097
098    /**
099     * set change
100     * @param change value to be set
101     */
102
103    public void setChange(final String change);
104
105    /**
106     *  <p>Value before the change.</p>
107     * @param previousValue values to be set
108     */
109
110    @JsonIgnore
111    public void setPreviousValue(final Price... previousValue);
112
113    /**
114     *  <p>Value before the change.</p>
115     * @param previousValue values to be set
116     */
117
118    public void setPreviousValue(final List<Price> previousValue);
119
120    /**
121     *  <p>Value after the change.</p>
122     * @param nextValue values to be set
123     */
124
125    @JsonIgnore
126    public void setNextValue(final Price... nextValue);
127
128    /**
129     *  <p>Value after the change.</p>
130     * @param nextValue values to be set
131     */
132
133    public void setNextValue(final List<Price> nextValue);
134
135    /**
136     *  <ul>
137     *   <li><code>staged</code>, if the staged ProductCatalogData was updated.</li>
138     *   <li><code>current</code>, if the current ProductCatalogData was updated.</li>
139     *  </ul>
140     * @param catalogData value to be set
141     */
142
143    public void setCatalogData(final String catalogData);
144
145    /**
146     *  <p><code>sku</code> or <code>key</code> of the ProductVariant.</p>
147     * @param variant value to be set
148     */
149
150    public void setVariant(final String variant);
151
152    /**
153     * factory method
154     * @return instance of SetPricesChange
155     */
156    public static SetPricesChange of() {
157        return new SetPricesChangeImpl();
158    }
159
160    /**
161     * factory method to create a shallow copy SetPricesChange
162     * @param template instance to be copied
163     * @return copy instance
164     */
165    public static SetPricesChange of(final SetPricesChange template) {
166        SetPricesChangeImpl instance = new SetPricesChangeImpl();
167        instance.setChange(template.getChange());
168        instance.setPreviousValue(template.getPreviousValue());
169        instance.setNextValue(template.getNextValue());
170        instance.setCatalogData(template.getCatalogData());
171        instance.setVariant(template.getVariant());
172        return instance;
173    }
174
175    /**
176     * factory method to create a deep copy of SetPricesChange
177     * @param template instance to be copied
178     * @return copy instance
179     */
180    @Nullable
181    public static SetPricesChange deepCopy(@Nullable final SetPricesChange template) {
182        if (template == null) {
183            return null;
184        }
185        SetPricesChangeImpl instance = new SetPricesChangeImpl();
186        instance.setChange(template.getChange());
187        instance.setPreviousValue(Optional.ofNullable(template.getPreviousValue())
188                .map(t -> t.stream()
189                        .map(com.commercetools.history.models.common.Price::deepCopy)
190                        .collect(Collectors.toList()))
191                .orElse(null));
192        instance.setNextValue(Optional.ofNullable(template.getNextValue())
193                .map(t -> t.stream()
194                        .map(com.commercetools.history.models.common.Price::deepCopy)
195                        .collect(Collectors.toList()))
196                .orElse(null));
197        instance.setCatalogData(template.getCatalogData());
198        instance.setVariant(template.getVariant());
199        return instance;
200    }
201
202    /**
203     * builder factory method for SetPricesChange
204     * @return builder
205     */
206    public static SetPricesChangeBuilder builder() {
207        return SetPricesChangeBuilder.of();
208    }
209
210    /**
211     * create builder for SetPricesChange instance
212     * @param template instance with prefilled values for the builder
213     * @return builder
214     */
215    public static SetPricesChangeBuilder builder(final SetPricesChange template) {
216        return SetPricesChangeBuilder.of(template);
217    }
218
219    /**
220     * accessor map function
221     * @param <T> mapped type
222     * @param helper function to map the object
223     * @return mapped value
224     */
225    default <T> T withSetPricesChange(Function<SetPricesChange, T> helper) {
226        return helper.apply(this);
227    }
228
229    /**
230     * gives a TypeReference for usage with Jackson DataBind
231     * @return TypeReference
232     */
233    public static com.fasterxml.jackson.core.type.TypeReference<SetPricesChange> typeReference() {
234        return new com.fasterxml.jackson.core.type.TypeReference<SetPricesChange>() {
235            @Override
236            public String toString() {
237                return "TypeReference<SetPricesChange>";
238            }
239        };
240    }
241}