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