001
002package com.commercetools.history.models.common;
003
004import java.util.*;
005import java.util.function.Function;
006
007import javax.annotation.Nullable;
008
009import io.vrap.rmf.base.client.Builder;
010import io.vrap.rmf.base.client.utils.Generated;
011
012/**
013 * DeliveryBuilder
014 * <hr>
015 * Example to create an instance using the builder pattern
016 * <div class=code-example>
017 * <pre><code class='java'>
018 *     Delivery delivery = Delivery.builder()
019 *             .id("{id}")
020 *             .createdAt("{createdAt}")
021 *             .plusItems(itemsBuilder -> itemsBuilder)
022 *             .plusParcels(parcelsBuilder -> parcelsBuilder)
023 *             .build()
024 * </code></pre>
025 * </div>
026 */
027@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen")
028public class DeliveryBuilder implements Builder<Delivery> {
029
030    private String id;
031
032    private String createdAt;
033
034    private java.util.List<com.commercetools.history.models.common.DeliveryItem> items;
035
036    private java.util.List<com.commercetools.history.models.common.Parcel> parcels;
037
038    @Nullable
039    private com.commercetools.history.models.common.Address address;
040
041    @Nullable
042    private com.commercetools.history.models.common.CustomFields custom;
043
044    /**
045     * set the value to the id
046     * @param id value to be set
047     * @return Builder
048     */
049
050    public DeliveryBuilder id(final String id) {
051        this.id = id;
052        return this;
053    }
054
055    /**
056     * set the value to the createdAt
057     * @param createdAt value to be set
058     * @return Builder
059     */
060
061    public DeliveryBuilder createdAt(final String createdAt) {
062        this.createdAt = createdAt;
063        return this;
064    }
065
066    /**
067     * set values to the items
068     * @param items value to be set
069     * @return Builder
070     */
071
072    public DeliveryBuilder items(final com.commercetools.history.models.common.DeliveryItem... items) {
073        this.items = new ArrayList<>(Arrays.asList(items));
074        return this;
075    }
076
077    /**
078     * set value to the items
079     * @param items value to be set
080     * @return Builder
081     */
082
083    public DeliveryBuilder items(final java.util.List<com.commercetools.history.models.common.DeliveryItem> items) {
084        this.items = items;
085        return this;
086    }
087
088    /**
089     * add values to the items
090     * @param items value to be set
091     * @return Builder
092     */
093
094    public DeliveryBuilder plusItems(final com.commercetools.history.models.common.DeliveryItem... items) {
095        if (this.items == null) {
096            this.items = new ArrayList<>();
097        }
098        this.items.addAll(Arrays.asList(items));
099        return this;
100    }
101
102    /**
103     * add the value to the items using the builder function
104     * @param builder function to build the items value
105     * @return Builder
106     */
107
108    public DeliveryBuilder plusItems(
109            Function<com.commercetools.history.models.common.DeliveryItemBuilder, com.commercetools.history.models.common.DeliveryItemBuilder> builder) {
110        if (this.items == null) {
111            this.items = new ArrayList<>();
112        }
113        this.items.add(builder.apply(com.commercetools.history.models.common.DeliveryItemBuilder.of()).build());
114        return this;
115    }
116
117    /**
118     * set the value to the items using the builder function
119     * @param builder function to build the items value
120     * @return Builder
121     */
122
123    public DeliveryBuilder withItems(
124            Function<com.commercetools.history.models.common.DeliveryItemBuilder, com.commercetools.history.models.common.DeliveryItemBuilder> builder) {
125        this.items = new ArrayList<>();
126        this.items.add(builder.apply(com.commercetools.history.models.common.DeliveryItemBuilder.of()).build());
127        return this;
128    }
129
130    /**
131     * add the value to the items using the builder function
132     * @param builder function to build the items value
133     * @return Builder
134     */
135
136    public DeliveryBuilder addItems(
137            Function<com.commercetools.history.models.common.DeliveryItemBuilder, com.commercetools.history.models.common.DeliveryItem> builder) {
138        return plusItems(builder.apply(com.commercetools.history.models.common.DeliveryItemBuilder.of()));
139    }
140
141    /**
142     * set the value to the items using the builder function
143     * @param builder function to build the items value
144     * @return Builder
145     */
146
147    public DeliveryBuilder setItems(
148            Function<com.commercetools.history.models.common.DeliveryItemBuilder, com.commercetools.history.models.common.DeliveryItem> builder) {
149        return items(builder.apply(com.commercetools.history.models.common.DeliveryItemBuilder.of()));
150    }
151
152    /**
153     * set values to the parcels
154     * @param parcels value to be set
155     * @return Builder
156     */
157
158    public DeliveryBuilder parcels(final com.commercetools.history.models.common.Parcel... parcels) {
159        this.parcels = new ArrayList<>(Arrays.asList(parcels));
160        return this;
161    }
162
163    /**
164     * set value to the parcels
165     * @param parcels value to be set
166     * @return Builder
167     */
168
169    public DeliveryBuilder parcels(final java.util.List<com.commercetools.history.models.common.Parcel> parcels) {
170        this.parcels = parcels;
171        return this;
172    }
173
174    /**
175     * add values to the parcels
176     * @param parcels value to be set
177     * @return Builder
178     */
179
180    public DeliveryBuilder plusParcels(final com.commercetools.history.models.common.Parcel... parcels) {
181        if (this.parcels == null) {
182            this.parcels = new ArrayList<>();
183        }
184        this.parcels.addAll(Arrays.asList(parcels));
185        return this;
186    }
187
188    /**
189     * add the value to the parcels using the builder function
190     * @param builder function to build the parcels value
191     * @return Builder
192     */
193
194    public DeliveryBuilder plusParcels(
195            Function<com.commercetools.history.models.common.ParcelBuilder, com.commercetools.history.models.common.ParcelBuilder> builder) {
196        if (this.parcels == null) {
197            this.parcels = new ArrayList<>();
198        }
199        this.parcels.add(builder.apply(com.commercetools.history.models.common.ParcelBuilder.of()).build());
200        return this;
201    }
202
203    /**
204     * set the value to the parcels using the builder function
205     * @param builder function to build the parcels value
206     * @return Builder
207     */
208
209    public DeliveryBuilder withParcels(
210            Function<com.commercetools.history.models.common.ParcelBuilder, com.commercetools.history.models.common.ParcelBuilder> builder) {
211        this.parcels = new ArrayList<>();
212        this.parcels.add(builder.apply(com.commercetools.history.models.common.ParcelBuilder.of()).build());
213        return this;
214    }
215
216    /**
217     * add the value to the parcels using the builder function
218     * @param builder function to build the parcels value
219     * @return Builder
220     */
221
222    public DeliveryBuilder addParcels(
223            Function<com.commercetools.history.models.common.ParcelBuilder, com.commercetools.history.models.common.Parcel> builder) {
224        return plusParcels(builder.apply(com.commercetools.history.models.common.ParcelBuilder.of()));
225    }
226
227    /**
228     * set the value to the parcels using the builder function
229     * @param builder function to build the parcels value
230     * @return Builder
231     */
232
233    public DeliveryBuilder setParcels(
234            Function<com.commercetools.history.models.common.ParcelBuilder, com.commercetools.history.models.common.Parcel> builder) {
235        return parcels(builder.apply(com.commercetools.history.models.common.ParcelBuilder.of()));
236    }
237
238    /**
239     * set the value to the address using the builder function
240     * @param builder function to build the address value
241     * @return Builder
242     */
243
244    public DeliveryBuilder address(
245            Function<com.commercetools.history.models.common.AddressBuilder, com.commercetools.history.models.common.AddressBuilder> builder) {
246        this.address = builder.apply(com.commercetools.history.models.common.AddressBuilder.of()).build();
247        return this;
248    }
249
250    /**
251     * set the value to the address using the builder function
252     * @param builder function to build the address value
253     * @return Builder
254     */
255
256    public DeliveryBuilder withAddress(
257            Function<com.commercetools.history.models.common.AddressBuilder, com.commercetools.history.models.common.Address> builder) {
258        this.address = builder.apply(com.commercetools.history.models.common.AddressBuilder.of());
259        return this;
260    }
261
262    /**
263     * set the value to the address
264     * @param address value to be set
265     * @return Builder
266     */
267
268    public DeliveryBuilder address(@Nullable final com.commercetools.history.models.common.Address address) {
269        this.address = address;
270        return this;
271    }
272
273    /**
274     *  <p>Custom Fields for the Transaction.</p>
275     * @param builder function to build the custom value
276     * @return Builder
277     */
278
279    public DeliveryBuilder custom(
280            Function<com.commercetools.history.models.common.CustomFieldsBuilder, com.commercetools.history.models.common.CustomFieldsBuilder> builder) {
281        this.custom = builder.apply(com.commercetools.history.models.common.CustomFieldsBuilder.of()).build();
282        return this;
283    }
284
285    /**
286     *  <p>Custom Fields for the Transaction.</p>
287     * @param builder function to build the custom value
288     * @return Builder
289     */
290
291    public DeliveryBuilder withCustom(
292            Function<com.commercetools.history.models.common.CustomFieldsBuilder, com.commercetools.history.models.common.CustomFields> builder) {
293        this.custom = builder.apply(com.commercetools.history.models.common.CustomFieldsBuilder.of());
294        return this;
295    }
296
297    /**
298     *  <p>Custom Fields for the Transaction.</p>
299     * @param custom value to be set
300     * @return Builder
301     */
302
303    public DeliveryBuilder custom(@Nullable final com.commercetools.history.models.common.CustomFields custom) {
304        this.custom = custom;
305        return this;
306    }
307
308    /**
309     * value of id}
310     * @return id
311     */
312
313    public String getId() {
314        return this.id;
315    }
316
317    /**
318     * value of createdAt}
319     * @return createdAt
320     */
321
322    public String getCreatedAt() {
323        return this.createdAt;
324    }
325
326    /**
327     * value of items}
328     * @return items
329     */
330
331    public java.util.List<com.commercetools.history.models.common.DeliveryItem> getItems() {
332        return this.items;
333    }
334
335    /**
336     * value of parcels}
337     * @return parcels
338     */
339
340    public java.util.List<com.commercetools.history.models.common.Parcel> getParcels() {
341        return this.parcels;
342    }
343
344    /**
345     * value of address}
346     * @return address
347     */
348
349    @Nullable
350    public com.commercetools.history.models.common.Address getAddress() {
351        return this.address;
352    }
353
354    /**
355     *  <p>Custom Fields for the Transaction.</p>
356     * @return custom
357     */
358
359    @Nullable
360    public com.commercetools.history.models.common.CustomFields getCustom() {
361        return this.custom;
362    }
363
364    /**
365     * builds Delivery with checking for non-null required values
366     * @return Delivery
367     */
368    public Delivery build() {
369        Objects.requireNonNull(id, Delivery.class + ": id is missing");
370        Objects.requireNonNull(createdAt, Delivery.class + ": createdAt is missing");
371        Objects.requireNonNull(items, Delivery.class + ": items is missing");
372        Objects.requireNonNull(parcels, Delivery.class + ": parcels is missing");
373        return new DeliveryImpl(id, createdAt, items, parcels, address, custom);
374    }
375
376    /**
377     * builds Delivery without checking for non-null required values
378     * @return Delivery
379     */
380    public Delivery buildUnchecked() {
381        return new DeliveryImpl(id, createdAt, items, parcels, address, custom);
382    }
383
384    /**
385     * factory method for an instance of DeliveryBuilder
386     * @return builder
387     */
388    public static DeliveryBuilder of() {
389        return new DeliveryBuilder();
390    }
391
392    /**
393     * create builder for Delivery instance
394     * @param template instance with prefilled values for the builder
395     * @return builder
396     */
397    public static DeliveryBuilder of(final Delivery template) {
398        DeliveryBuilder builder = new DeliveryBuilder();
399        builder.id = template.getId();
400        builder.createdAt = template.getCreatedAt();
401        builder.items = template.getItems();
402        builder.parcels = template.getParcels();
403        builder.address = template.getAddress();
404        builder.custom = template.getCustom();
405        return builder;
406    }
407
408}