001
002package com.commercetools.history.models.common;
003
004import java.util.*;
005
006import io.vrap.rmf.base.client.Builder;
007import io.vrap.rmf.base.client.utils.Generated;
008
009/**
010 * ItemShippingTargetBuilder
011 * <hr>
012 * Example to create an instance using the builder pattern
013 * <div class=code-example>
014 * <pre><code class='java'>
015 *     ItemShippingTarget itemShippingTarget = ItemShippingTarget.builder()
016 *             .addressKey("{addressKey}")
017 *             .quantity(1)
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 ItemShippingTargetBuilder implements Builder<ItemShippingTarget> {
024
025    private String addressKey;
026
027    private Integer quantity;
028
029    /**
030     *  <p>The key of the address in the cart's <code>itemShippingAddresses</code></p>
031     * @param addressKey value to be set
032     * @return Builder
033     */
034
035    public ItemShippingTargetBuilder addressKey(final String addressKey) {
036        this.addressKey = addressKey;
037        return this;
038    }
039
040    /**
041     *  <p>The quantity of items that should go to the address with the specified <code>addressKey</code>. Only positive values are allowed. Using <code>0</code> as quantity is also possible in a draft object, but the element will not be present in the resulting ItemShippingDetails.</p>
042     * @param quantity value to be set
043     * @return Builder
044     */
045
046    public ItemShippingTargetBuilder quantity(final Integer quantity) {
047        this.quantity = quantity;
048        return this;
049    }
050
051    /**
052     *  <p>The key of the address in the cart's <code>itemShippingAddresses</code></p>
053     * @return addressKey
054     */
055
056    public String getAddressKey() {
057        return this.addressKey;
058    }
059
060    /**
061     *  <p>The quantity of items that should go to the address with the specified <code>addressKey</code>. Only positive values are allowed. Using <code>0</code> as quantity is also possible in a draft object, but the element will not be present in the resulting ItemShippingDetails.</p>
062     * @return quantity
063     */
064
065    public Integer getQuantity() {
066        return this.quantity;
067    }
068
069    /**
070     * builds ItemShippingTarget with checking for non-null required values
071     * @return ItemShippingTarget
072     */
073    public ItemShippingTarget build() {
074        Objects.requireNonNull(addressKey, ItemShippingTarget.class + ": addressKey is missing");
075        Objects.requireNonNull(quantity, ItemShippingTarget.class + ": quantity is missing");
076        return new ItemShippingTargetImpl(addressKey, quantity);
077    }
078
079    /**
080     * builds ItemShippingTarget without checking for non-null required values
081     * @return ItemShippingTarget
082     */
083    public ItemShippingTarget buildUnchecked() {
084        return new ItemShippingTargetImpl(addressKey, quantity);
085    }
086
087    /**
088     * factory method for an instance of ItemShippingTargetBuilder
089     * @return builder
090     */
091    public static ItemShippingTargetBuilder of() {
092        return new ItemShippingTargetBuilder();
093    }
094
095    /**
096     * create builder for ItemShippingTarget instance
097     * @param template instance with prefilled values for the builder
098     * @return builder
099     */
100    public static ItemShippingTargetBuilder of(final ItemShippingTarget template) {
101        ItemShippingTargetBuilder builder = new ItemShippingTargetBuilder();
102        builder.addressKey = template.getAddressKey();
103        builder.quantity = template.getQuantity();
104        return builder;
105    }
106
107}