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