001
002package com.commercetools.api.models.order;
003
004import java.util.*;
005
006import io.vrap.rmf.base.client.Builder;
007import io.vrap.rmf.base.client.utils.Generated;
008
009/**
010 * DeliveryItemBuilder
011 * <hr>
012 * Example to create an instance using the builder pattern
013 * <div class=code-example>
014 * <pre><code class='java'>
015 *     DeliveryItem deliveryItem = DeliveryItem.builder()
016 *             .id("{id}")
017 *             .quantity(0.3)
018 *             .build()
019 * </code></pre>
020 * </div>
021 */
022@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen")
023public class DeliveryItemBuilder implements Builder<DeliveryItem> {
024
025    private String id;
026
027    private Long quantity;
028
029    /**
030     *  <p>Unique identifier of the DeliveryItem.</p>
031     * @param id value to be set
032     * @return Builder
033     */
034
035    public DeliveryItemBuilder id(final String id) {
036        this.id = id;
037        return this;
038    }
039
040    /**
041     * set the value to the quantity
042     * @param quantity value to be set
043     * @return Builder
044     */
045
046    public DeliveryItemBuilder quantity(final Long quantity) {
047        this.quantity = quantity;
048        return this;
049    }
050
051    /**
052     *  <p>Unique identifier of the DeliveryItem.</p>
053     * @return id
054     */
055
056    public String getId() {
057        return this.id;
058    }
059
060    /**
061     * value of quantity}
062     * @return quantity
063     */
064
065    public Long getQuantity() {
066        return this.quantity;
067    }
068
069    /**
070     * builds DeliveryItem with checking for non-null required values
071     * @return DeliveryItem
072     */
073    public DeliveryItem build() {
074        Objects.requireNonNull(id, DeliveryItem.class + ": id is missing");
075        Objects.requireNonNull(quantity, DeliveryItem.class + ": quantity is missing");
076        return new DeliveryItemImpl(id, quantity);
077    }
078
079    /**
080     * builds DeliveryItem without checking for non-null required values
081     * @return DeliveryItem
082     */
083    public DeliveryItem buildUnchecked() {
084        return new DeliveryItemImpl(id, quantity);
085    }
086
087    /**
088     * factory method for an instance of DeliveryItemBuilder
089     * @return builder
090     */
091    public static DeliveryItemBuilder of() {
092        return new DeliveryItemBuilder();
093    }
094
095    /**
096     * create builder for DeliveryItem instance
097     * @param template instance with prefilled values for the builder
098     * @return builder
099     */
100    public static DeliveryItemBuilder of(final DeliveryItem template) {
101        DeliveryItemBuilder builder = new DeliveryItemBuilder();
102        builder.id = template.getId();
103        builder.quantity = template.getQuantity();
104        return builder;
105    }
106
107}