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 CustomLineItem according to allowed transitions on Orders.</li>
023 *   <li>Change the state of CustomLineItem 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 *     TransitionCustomLineItemStateChange transitionCustomLineItemStateChange = TransitionCustomLineItemStateChange.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 = TransitionCustomLineItemStateChangeImpl.class)
042public interface TransitionCustomLineItemStateChange extends Change {
043
044    /**
045     * discriminator value for TransitionCustomLineItemStateChange
046     */
047    String TRANSITION_CUSTOM_LINE_ITEM_STATE_CHANGE = "TransitionCustomLineItemStateChange";
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 CustomLineItem.</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 CustomLineItem.</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 TransitionCustomLineItemStateChange
153     */
154    public static TransitionCustomLineItemStateChange of() {
155        return new TransitionCustomLineItemStateChangeImpl();
156    }
157
158    /**
159     * factory method to create a shallow copy TransitionCustomLineItemStateChange
160     * @param template instance to be copied
161     * @return copy instance
162     */
163    public static TransitionCustomLineItemStateChange of(final TransitionCustomLineItemStateChange template) {
164        TransitionCustomLineItemStateChangeImpl instance = new TransitionCustomLineItemStateChangeImpl();
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 TransitionCustomLineItemStateChange
175     * @param template instance to be copied
176     * @return copy instance
177     */
178    @Nullable
179    public static TransitionCustomLineItemStateChange deepCopy(
180            @Nullable final TransitionCustomLineItemStateChange template) {
181        if (template == null) {
182            return null;
183        }
184        TransitionCustomLineItemStateChangeImpl instance = new TransitionCustomLineItemStateChangeImpl();
185        instance.setChange(template.getChange());
186        instance.setPreviousValue(Optional.ofNullable(template.getPreviousValue())
187                .map(t -> t.stream()
188                        .map(com.commercetools.history.models.common.ItemState::deepCopy)
189                        .collect(Collectors.toList()))
190                .orElse(null));
191        instance.setNextValue(Optional.ofNullable(template.getNextValue())
192                .map(t -> t.stream()
193                        .map(com.commercetools.history.models.common.ItemState::deepCopy)
194                        .collect(Collectors.toList()))
195                .orElse(null));
196        instance.setLineItemId(template.getLineItemId());
197        instance.setStateId(template.getStateId());
198        return instance;
199    }
200
201    /**
202     * builder factory method for TransitionCustomLineItemStateChange
203     * @return builder
204     */
205    public static TransitionCustomLineItemStateChangeBuilder builder() {
206        return TransitionCustomLineItemStateChangeBuilder.of();
207    }
208
209    /**
210     * create builder for TransitionCustomLineItemStateChange instance
211     * @param template instance with prefilled values for the builder
212     * @return builder
213     */
214    public static TransitionCustomLineItemStateChangeBuilder builder(
215            final TransitionCustomLineItemStateChange template) {
216        return TransitionCustomLineItemStateChangeBuilder.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 withTransitionCustomLineItemStateChange(Function<TransitionCustomLineItemStateChange, 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<TransitionCustomLineItemStateChange> typeReference() {
234        return new com.fasterxml.jackson.core.type.TypeReference<TransitionCustomLineItemStateChange>() {
235            @Override
236            public String toString() {
237                return "TypeReference<TransitionCustomLineItemStateChange>";
238            }
239        };
240    }
241}