001
002package com.commercetools.history.models.change;
003
004import java.util.*;
005import java.util.function.Function;
006
007import io.vrap.rmf.base.client.Builder;
008import io.vrap.rmf.base.client.utils.Generated;
009
010/**
011 * TransitionLineItemStateChangeBuilder
012 * <hr>
013 * Example to create an instance using the builder pattern
014 * <div class=code-example>
015 * <pre><code class='java'>
016 *     TransitionLineItemStateChange transitionLineItemStateChange = TransitionLineItemStateChange.builder()
017 *             .change("{change}")
018 *             .plusPreviousValue(previousValueBuilder -> previousValueBuilder)
019 *             .plusNextValue(nextValueBuilder -> nextValueBuilder)
020 *             .lineItemId("{lineItemId}")
021 *             .stateId("{stateId}")
022 *             .build()
023 * </code></pre>
024 * </div>
025 */
026@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen")
027public class TransitionLineItemStateChangeBuilder implements Builder<TransitionLineItemStateChange> {
028
029    private String change;
030
031    private java.util.List<com.commercetools.history.models.common.ItemState> previousValue;
032
033    private java.util.List<com.commercetools.history.models.common.ItemState> nextValue;
034
035    private String lineItemId;
036
037    private String stateId;
038
039    /**
040     * set the value to the change
041     * @param change value to be set
042     * @return Builder
043     */
044
045    public TransitionLineItemStateChangeBuilder change(final String change) {
046        this.change = change;
047        return this;
048    }
049
050    /**
051     *  <p>Value before the change.</p>
052     * @param previousValue value to be set
053     * @return Builder
054     */
055
056    public TransitionLineItemStateChangeBuilder previousValue(
057            final com.commercetools.history.models.common.ItemState... previousValue) {
058        this.previousValue = new ArrayList<>(Arrays.asList(previousValue));
059        return this;
060    }
061
062    /**
063     *  <p>Value before the change.</p>
064     * @param previousValue value to be set
065     * @return Builder
066     */
067
068    public TransitionLineItemStateChangeBuilder previousValue(
069            final java.util.List<com.commercetools.history.models.common.ItemState> previousValue) {
070        this.previousValue = previousValue;
071        return this;
072    }
073
074    /**
075     *  <p>Value before the change.</p>
076     * @param previousValue value to be set
077     * @return Builder
078     */
079
080    public TransitionLineItemStateChangeBuilder plusPreviousValue(
081            final com.commercetools.history.models.common.ItemState... previousValue) {
082        if (this.previousValue == null) {
083            this.previousValue = new ArrayList<>();
084        }
085        this.previousValue.addAll(Arrays.asList(previousValue));
086        return this;
087    }
088
089    /**
090     *  <p>Value before the change.</p>
091     * @param builder function to build the previousValue value
092     * @return Builder
093     */
094
095    public TransitionLineItemStateChangeBuilder plusPreviousValue(
096            Function<com.commercetools.history.models.common.ItemStateBuilder, com.commercetools.history.models.common.ItemStateBuilder> builder) {
097        if (this.previousValue == null) {
098            this.previousValue = new ArrayList<>();
099        }
100        this.previousValue.add(builder.apply(com.commercetools.history.models.common.ItemStateBuilder.of()).build());
101        return this;
102    }
103
104    /**
105     *  <p>Value before the change.</p>
106     * @param builder function to build the previousValue value
107     * @return Builder
108     */
109
110    public TransitionLineItemStateChangeBuilder withPreviousValue(
111            Function<com.commercetools.history.models.common.ItemStateBuilder, com.commercetools.history.models.common.ItemStateBuilder> builder) {
112        this.previousValue = new ArrayList<>();
113        this.previousValue.add(builder.apply(com.commercetools.history.models.common.ItemStateBuilder.of()).build());
114        return this;
115    }
116
117    /**
118     *  <p>Value before the change.</p>
119     * @param builder function to build the previousValue value
120     * @return Builder
121     */
122
123    public TransitionLineItemStateChangeBuilder addPreviousValue(
124            Function<com.commercetools.history.models.common.ItemStateBuilder, com.commercetools.history.models.common.ItemState> builder) {
125        return plusPreviousValue(builder.apply(com.commercetools.history.models.common.ItemStateBuilder.of()));
126    }
127
128    /**
129     *  <p>Value before the change.</p>
130     * @param builder function to build the previousValue value
131     * @return Builder
132     */
133
134    public TransitionLineItemStateChangeBuilder setPreviousValue(
135            Function<com.commercetools.history.models.common.ItemStateBuilder, com.commercetools.history.models.common.ItemState> builder) {
136        return previousValue(builder.apply(com.commercetools.history.models.common.ItemStateBuilder.of()));
137    }
138
139    /**
140     *  <p>Value after the change.</p>
141     * @param nextValue value to be set
142     * @return Builder
143     */
144
145    public TransitionLineItemStateChangeBuilder nextValue(
146            final com.commercetools.history.models.common.ItemState... nextValue) {
147        this.nextValue = new ArrayList<>(Arrays.asList(nextValue));
148        return this;
149    }
150
151    /**
152     *  <p>Value after the change.</p>
153     * @param nextValue value to be set
154     * @return Builder
155     */
156
157    public TransitionLineItemStateChangeBuilder nextValue(
158            final java.util.List<com.commercetools.history.models.common.ItemState> nextValue) {
159        this.nextValue = nextValue;
160        return this;
161    }
162
163    /**
164     *  <p>Value after the change.</p>
165     * @param nextValue value to be set
166     * @return Builder
167     */
168
169    public TransitionLineItemStateChangeBuilder plusNextValue(
170            final com.commercetools.history.models.common.ItemState... nextValue) {
171        if (this.nextValue == null) {
172            this.nextValue = new ArrayList<>();
173        }
174        this.nextValue.addAll(Arrays.asList(nextValue));
175        return this;
176    }
177
178    /**
179     *  <p>Value after the change.</p>
180     * @param builder function to build the nextValue value
181     * @return Builder
182     */
183
184    public TransitionLineItemStateChangeBuilder plusNextValue(
185            Function<com.commercetools.history.models.common.ItemStateBuilder, com.commercetools.history.models.common.ItemStateBuilder> builder) {
186        if (this.nextValue == null) {
187            this.nextValue = new ArrayList<>();
188        }
189        this.nextValue.add(builder.apply(com.commercetools.history.models.common.ItemStateBuilder.of()).build());
190        return this;
191    }
192
193    /**
194     *  <p>Value after the change.</p>
195     * @param builder function to build the nextValue value
196     * @return Builder
197     */
198
199    public TransitionLineItemStateChangeBuilder withNextValue(
200            Function<com.commercetools.history.models.common.ItemStateBuilder, com.commercetools.history.models.common.ItemStateBuilder> builder) {
201        this.nextValue = new ArrayList<>();
202        this.nextValue.add(builder.apply(com.commercetools.history.models.common.ItemStateBuilder.of()).build());
203        return this;
204    }
205
206    /**
207     *  <p>Value after the change.</p>
208     * @param builder function to build the nextValue value
209     * @return Builder
210     */
211
212    public TransitionLineItemStateChangeBuilder addNextValue(
213            Function<com.commercetools.history.models.common.ItemStateBuilder, com.commercetools.history.models.common.ItemState> builder) {
214        return plusNextValue(builder.apply(com.commercetools.history.models.common.ItemStateBuilder.of()));
215    }
216
217    /**
218     *  <p>Value after the change.</p>
219     * @param builder function to build the nextValue value
220     * @return Builder
221     */
222
223    public TransitionLineItemStateChangeBuilder setNextValue(
224            Function<com.commercetools.history.models.common.ItemStateBuilder, com.commercetools.history.models.common.ItemState> builder) {
225        return nextValue(builder.apply(com.commercetools.history.models.common.ItemStateBuilder.of()));
226    }
227
228    /**
229     *  <p><code>id</code> of the updated LineItem.</p>
230     * @param lineItemId value to be set
231     * @return Builder
232     */
233
234    public TransitionLineItemStateChangeBuilder lineItemId(final String lineItemId) {
235        this.lineItemId = lineItemId;
236        return this;
237    }
238
239    /**
240     *  <p><code>id</code> of the State involved in the transition.</p>
241     * @param stateId value to be set
242     * @return Builder
243     */
244
245    public TransitionLineItemStateChangeBuilder stateId(final String stateId) {
246        this.stateId = stateId;
247        return this;
248    }
249
250    /**
251     * value of change}
252     * @return change
253     */
254
255    public String getChange() {
256        return this.change;
257    }
258
259    /**
260     *  <p>Value before the change.</p>
261     * @return previousValue
262     */
263
264    public java.util.List<com.commercetools.history.models.common.ItemState> getPreviousValue() {
265        return this.previousValue;
266    }
267
268    /**
269     *  <p>Value after the change.</p>
270     * @return nextValue
271     */
272
273    public java.util.List<com.commercetools.history.models.common.ItemState> getNextValue() {
274        return this.nextValue;
275    }
276
277    /**
278     *  <p><code>id</code> of the updated LineItem.</p>
279     * @return lineItemId
280     */
281
282    public String getLineItemId() {
283        return this.lineItemId;
284    }
285
286    /**
287     *  <p><code>id</code> of the State involved in the transition.</p>
288     * @return stateId
289     */
290
291    public String getStateId() {
292        return this.stateId;
293    }
294
295    /**
296     * builds TransitionLineItemStateChange with checking for non-null required values
297     * @return TransitionLineItemStateChange
298     */
299    public TransitionLineItemStateChange build() {
300        Objects.requireNonNull(change, TransitionLineItemStateChange.class + ": change is missing");
301        Objects.requireNonNull(previousValue, TransitionLineItemStateChange.class + ": previousValue is missing");
302        Objects.requireNonNull(nextValue, TransitionLineItemStateChange.class + ": nextValue is missing");
303        Objects.requireNonNull(lineItemId, TransitionLineItemStateChange.class + ": lineItemId is missing");
304        Objects.requireNonNull(stateId, TransitionLineItemStateChange.class + ": stateId is missing");
305        return new TransitionLineItemStateChangeImpl(change, previousValue, nextValue, lineItemId, stateId);
306    }
307
308    /**
309     * builds TransitionLineItemStateChange without checking for non-null required values
310     * @return TransitionLineItemStateChange
311     */
312    public TransitionLineItemStateChange buildUnchecked() {
313        return new TransitionLineItemStateChangeImpl(change, previousValue, nextValue, lineItemId, stateId);
314    }
315
316    /**
317     * factory method for an instance of TransitionLineItemStateChangeBuilder
318     * @return builder
319     */
320    public static TransitionLineItemStateChangeBuilder of() {
321        return new TransitionLineItemStateChangeBuilder();
322    }
323
324    /**
325     * create builder for TransitionLineItemStateChange instance
326     * @param template instance with prefilled values for the builder
327     * @return builder
328     */
329    public static TransitionLineItemStateChangeBuilder of(final TransitionLineItemStateChange template) {
330        TransitionLineItemStateChangeBuilder builder = new TransitionLineItemStateChangeBuilder();
331        builder.change = template.getChange();
332        builder.previousValue = template.getPreviousValue();
333        builder.nextValue = template.getNextValue();
334        builder.lineItemId = template.getLineItemId();
335        builder.stateId = template.getStateId();
336        return builder;
337    }
338
339}