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.ItemState;
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 following update actions:</p>
021 *  <ul>
022 *   <li>Change the state of LineItem according to allowed transitions on Orders.</li>
023 *   <li>Change the state of LineItem according to allowed transitions on Staged Orders.</li>
024 *  </ul>
025 *
026 * <hr>
027 * Example to create an instance using the builder pattern
028 * <div class=code-example>
029 * <pre><code class='java'>
030 *     TransitionLineItemStateChange transitionLineItemStateChange = TransitionLineItemStateChange.builder()
031 *             .change("{change}")
032 *             .plusPreviousValue(previousValueBuilder -> previousValueBuilder)
033 *             .plusNextValue(nextValueBuilder -> nextValueBuilder)
034 *             .lineItemId("{lineItemId}")
035 *             .stateId("{stateId}")
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 = TransitionLineItemStateChangeImpl.class)
042public interface TransitionLineItemStateChange extends Change {
043
044    /**
045     * discriminator value for TransitionLineItemStateChange
046     */
047    String TRANSITION_LINE_ITEM_STATE_CHANGE = "TransitionLineItemStateChange";
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<ItemState> getPreviousValue();
073
074    /**
075     *  <p>Value after the change.</p>
076     * @return nextValue
077     */
078    @NotNull
079    @Valid
080    @JsonProperty("nextValue")
081    public List<ItemState> getNextValue();
082
083    /**
084     *  <p><code>id</code> of the updated LineItem.</p>
085     * @return lineItemId
086     */
087    @NotNull
088    @JsonProperty("lineItemId")
089    public String getLineItemId();
090
091    /**
092     *  <p><code>id</code> of the State involved in the transition.</p>
093     * @return stateId
094     */
095    @NotNull
096    @JsonProperty("stateId")
097    public String getStateId();
098
099    /**
100     * set change
101     * @param change value to be set
102     */
103
104    public void setChange(final String change);
105
106    /**
107     *  <p>Value before the change.</p>
108     * @param previousValue values to be set
109     */
110
111    @JsonIgnore
112    public void setPreviousValue(final ItemState... previousValue);
113
114    /**
115     *  <p>Value before the change.</p>
116     * @param previousValue values to be set
117     */
118
119    public void setPreviousValue(final List<ItemState> previousValue);
120
121    /**
122     *  <p>Value after the change.</p>
123     * @param nextValue values to be set
124     */
125
126    @JsonIgnore
127    public void setNextValue(final ItemState... nextValue);
128
129    /**
130     *  <p>Value after the change.</p>
131     * @param nextValue values to be set
132     */
133
134    public void setNextValue(final List<ItemState> nextValue);
135
136    /**
137     *  <p><code>id</code> of the updated LineItem.</p>
138     * @param lineItemId value to be set
139     */
140
141    public void setLineItemId(final String lineItemId);
142
143    /**
144     *  <p><code>id</code> of the State involved in the transition.</p>
145     * @param stateId value to be set
146     */
147
148    public void setStateId(final String stateId);
149
150    /**
151     * factory method
152     * @return instance of TransitionLineItemStateChange
153     */
154    public static TransitionLineItemStateChange of() {
155        return new TransitionLineItemStateChangeImpl();
156    }
157
158    /**
159     * factory method to create a shallow copy TransitionLineItemStateChange
160     * @param template instance to be copied
161     * @return copy instance
162     */
163    public static TransitionLineItemStateChange of(final TransitionLineItemStateChange template) {
164        TransitionLineItemStateChangeImpl instance = new TransitionLineItemStateChangeImpl();
165        instance.setChange(template.getChange());
166        instance.setPreviousValue(template.getPreviousValue());
167        instance.setNextValue(template.getNextValue());
168        instance.setLineItemId(template.getLineItemId());
169        instance.setStateId(template.getStateId());
170        return instance;
171    }
172
173    /**
174     * factory method to create a deep copy of TransitionLineItemStateChange
175     * @param template instance to be copied
176     * @return copy instance
177     */
178    @Nullable
179    public static TransitionLineItemStateChange deepCopy(@Nullable final TransitionLineItemStateChange template) {
180        if (template == null) {
181            return null;
182        }
183        TransitionLineItemStateChangeImpl instance = new TransitionLineItemStateChangeImpl();
184        instance.setChange(template.getChange());
185        instance.setPreviousValue(Optional.ofNullable(template.getPreviousValue())
186                .map(t -> t.stream()
187                        .map(com.commercetools.history.models.common.ItemState::deepCopy)
188                        .collect(Collectors.toList()))
189                .orElse(null));
190        instance.setNextValue(Optional.ofNullable(template.getNextValue())
191                .map(t -> t.stream()
192                        .map(com.commercetools.history.models.common.ItemState::deepCopy)
193                        .collect(Collectors.toList()))
194                .orElse(null));
195        instance.setLineItemId(template.getLineItemId());
196        instance.setStateId(template.getStateId());
197        return instance;
198    }
199
200    /**
201     * builder factory method for TransitionLineItemStateChange
202     * @return builder
203     */
204    public static TransitionLineItemStateChangeBuilder builder() {
205        return TransitionLineItemStateChangeBuilder.of();
206    }
207
208    /**
209     * create builder for TransitionLineItemStateChange instance
210     * @param template instance with prefilled values for the builder
211     * @return builder
212     */
213    public static TransitionLineItemStateChangeBuilder builder(final TransitionLineItemStateChange template) {
214        return TransitionLineItemStateChangeBuilder.of(template);
215    }
216
217    /**
218     * accessor map function
219     * @param <T> mapped type
220     * @param helper function to map the object
221     * @return mapped value
222     */
223    default <T> T withTransitionLineItemStateChange(Function<TransitionLineItemStateChange, T> helper) {
224        return helper.apply(this);
225    }
226
227    /**
228     * gives a TypeReference for usage with Jackson DataBind
229     * @return TypeReference
230     */
231    public static com.fasterxml.jackson.core.type.TypeReference<TransitionLineItemStateChange> typeReference() {
232        return new com.fasterxml.jackson.core.type.TypeReference<TransitionLineItemStateChange>() {
233            @Override
234            public String toString() {
235                return "TypeReference<TransitionLineItemStateChange>";
236            }
237        };
238    }
239}