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.Reference;
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 Change CartDiscounts 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 *     ChangeCartDiscountsChange changeCartDiscountsChange = ChangeCartDiscountsChange.builder()
027 *             .change("{change}")
028 *             .plusPreviousValue(previousValueBuilder -> previousValueBuilder)
029 *             .plusNextValue(nextValueBuilder -> nextValueBuilder)
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 = ChangeCartDiscountsChangeImpl.class)
036public interface ChangeCartDiscountsChange extends Change {
037
038    /**
039     * discriminator value for ChangeCartDiscountsChange
040     */
041    String CHANGE_CART_DISCOUNTS_CHANGE = "ChangeCartDiscountsChange";
042
043    /**
044     *
045     * @return type
046     */
047    @NotNull
048    @JsonProperty("type")
049    public String getType();
050
051    /**
052     *
053     * @return change
054     */
055    @NotNull
056    @JsonProperty("change")
057    public String getChange();
058
059    /**
060     *  <p>Value before the change.</p>
061     * @return previousValue
062     */
063    @NotNull
064    @Valid
065    @JsonProperty("previousValue")
066    public List<Reference> getPreviousValue();
067
068    /**
069     *  <p>Value after the change.</p>
070     * @return nextValue
071     */
072    @NotNull
073    @Valid
074    @JsonProperty("nextValue")
075    public List<Reference> getNextValue();
076
077    /**
078     * set change
079     * @param change value to be set
080     */
081
082    public void setChange(final String change);
083
084    /**
085     *  <p>Value before the change.</p>
086     * @param previousValue values to be set
087     */
088
089    @JsonIgnore
090    public void setPreviousValue(final Reference... previousValue);
091
092    /**
093     *  <p>Value before the change.</p>
094     * @param previousValue values to be set
095     */
096
097    public void setPreviousValue(final List<Reference> previousValue);
098
099    /**
100     *  <p>Value after the change.</p>
101     * @param nextValue values to be set
102     */
103
104    @JsonIgnore
105    public void setNextValue(final Reference... nextValue);
106
107    /**
108     *  <p>Value after the change.</p>
109     * @param nextValue values to be set
110     */
111
112    public void setNextValue(final List<Reference> nextValue);
113
114    /**
115     * factory method
116     * @return instance of ChangeCartDiscountsChange
117     */
118    public static ChangeCartDiscountsChange of() {
119        return new ChangeCartDiscountsChangeImpl();
120    }
121
122    /**
123     * factory method to create a shallow copy ChangeCartDiscountsChange
124     * @param template instance to be copied
125     * @return copy instance
126     */
127    public static ChangeCartDiscountsChange of(final ChangeCartDiscountsChange template) {
128        ChangeCartDiscountsChangeImpl instance = new ChangeCartDiscountsChangeImpl();
129        instance.setChange(template.getChange());
130        instance.setPreviousValue(template.getPreviousValue());
131        instance.setNextValue(template.getNextValue());
132        return instance;
133    }
134
135    /**
136     * factory method to create a deep copy of ChangeCartDiscountsChange
137     * @param template instance to be copied
138     * @return copy instance
139     */
140    @Nullable
141    public static ChangeCartDiscountsChange deepCopy(@Nullable final ChangeCartDiscountsChange template) {
142        if (template == null) {
143            return null;
144        }
145        ChangeCartDiscountsChangeImpl instance = new ChangeCartDiscountsChangeImpl();
146        instance.setChange(template.getChange());
147        instance.setPreviousValue(Optional.ofNullable(template.getPreviousValue())
148                .map(t -> t.stream()
149                        .map(com.commercetools.history.models.common.Reference::deepCopy)
150                        .collect(Collectors.toList()))
151                .orElse(null));
152        instance.setNextValue(Optional.ofNullable(template.getNextValue())
153                .map(t -> t.stream()
154                        .map(com.commercetools.history.models.common.Reference::deepCopy)
155                        .collect(Collectors.toList()))
156                .orElse(null));
157        return instance;
158    }
159
160    /**
161     * builder factory method for ChangeCartDiscountsChange
162     * @return builder
163     */
164    public static ChangeCartDiscountsChangeBuilder builder() {
165        return ChangeCartDiscountsChangeBuilder.of();
166    }
167
168    /**
169     * create builder for ChangeCartDiscountsChange instance
170     * @param template instance with prefilled values for the builder
171     * @return builder
172     */
173    public static ChangeCartDiscountsChangeBuilder builder(final ChangeCartDiscountsChange template) {
174        return ChangeCartDiscountsChangeBuilder.of(template);
175    }
176
177    /**
178     * accessor map function
179     * @param <T> mapped type
180     * @param helper function to map the object
181     * @return mapped value
182     */
183    default <T> T withChangeCartDiscountsChange(Function<ChangeCartDiscountsChange, T> helper) {
184        return helper.apply(this);
185    }
186
187    /**
188     * gives a TypeReference for usage with Jackson DataBind
189     * @return TypeReference
190     */
191    public static com.fasterxml.jackson.core.type.TypeReference<ChangeCartDiscountsChange> typeReference() {
192        return new com.fasterxml.jackson.core.type.TypeReference<ChangeCartDiscountsChange>() {
193            @Override
194            public String toString() {
195                return "TypeReference<ChangeCartDiscountsChange>";
196            }
197        };
198    }
199}