001
002package com.commercetools.api.models.cart;
003
004import java.util.*;
005
006import javax.annotation.Nullable;
007
008import io.vrap.rmf.base.client.Builder;
009import io.vrap.rmf.base.client.utils.Generated;
010
011/**
012 * ItemShippingTargetBuilder
013 * <hr>
014 * Example to create an instance using the builder pattern
015 * <div class=code-example>
016 * <pre><code class='java'>
017 *     ItemShippingTarget itemShippingTarget = ItemShippingTarget.builder()
018 *             .addressKey("{addressKey}")
019 *             .quantity(0.3)
020 *             .build()
021 * </code></pre>
022 * </div>
023 */
024@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen")
025public class ItemShippingTargetBuilder implements Builder<ItemShippingTarget> {
026
027    private String addressKey;
028
029    private Long quantity;
030
031    @Nullable
032    private String shippingMethodKey;
033
034    /**
035     *  <p>Key of the address in the Cart <code>itemShippingAddresses</code>. Duplicate address keys are not allowed.</p>
036     * @param addressKey value to be set
037     * @return Builder
038     */
039
040    public ItemShippingTargetBuilder addressKey(final String addressKey) {
041        this.addressKey = addressKey;
042        return this;
043    }
044
045    /**
046     *  <p>Quantity of Line Items or Custom Line Items shipped to the address with the specified <code>addressKey</code>.</p>
047     *  <p>If a quantity is updated to <code>0</code> when defining ItemShippingDetailsDraft, the <code>targets</code> are removed from a Line Item or Custom Line Item in the resulting ItemShippingDetails.</p>
048     * @param quantity value to be set
049     * @return Builder
050     */
051
052    public ItemShippingTargetBuilder quantity(final Long quantity) {
053        this.quantity = quantity;
054        return this;
055    }
056
057    /**
058     *  <p>User-defined unique identifier of the Shipping Method in a Cart with <code>Multiple</code> ShippingMode.</p>
059     *  <p>It connects Line Item quantities with individual shipping addresses.</p>
060     * @param shippingMethodKey value to be set
061     * @return Builder
062     */
063
064    public ItemShippingTargetBuilder shippingMethodKey(@Nullable final String shippingMethodKey) {
065        this.shippingMethodKey = shippingMethodKey;
066        return this;
067    }
068
069    /**
070     *  <p>Key of the address in the Cart <code>itemShippingAddresses</code>. Duplicate address keys are not allowed.</p>
071     * @return addressKey
072     */
073
074    public String getAddressKey() {
075        return this.addressKey;
076    }
077
078    /**
079     *  <p>Quantity of Line Items or Custom Line Items shipped to the address with the specified <code>addressKey</code>.</p>
080     *  <p>If a quantity is updated to <code>0</code> when defining ItemShippingDetailsDraft, the <code>targets</code> are removed from a Line Item or Custom Line Item in the resulting ItemShippingDetails.</p>
081     * @return quantity
082     */
083
084    public Long getQuantity() {
085        return this.quantity;
086    }
087
088    /**
089     *  <p>User-defined unique identifier of the Shipping Method in a Cart with <code>Multiple</code> ShippingMode.</p>
090     *  <p>It connects Line Item quantities with individual shipping addresses.</p>
091     * @return shippingMethodKey
092     */
093
094    @Nullable
095    public String getShippingMethodKey() {
096        return this.shippingMethodKey;
097    }
098
099    /**
100     * builds ItemShippingTarget with checking for non-null required values
101     * @return ItemShippingTarget
102     */
103    public ItemShippingTarget build() {
104        Objects.requireNonNull(addressKey, ItemShippingTarget.class + ": addressKey is missing");
105        Objects.requireNonNull(quantity, ItemShippingTarget.class + ": quantity is missing");
106        return new ItemShippingTargetImpl(addressKey, quantity, shippingMethodKey);
107    }
108
109    /**
110     * builds ItemShippingTarget without checking for non-null required values
111     * @return ItemShippingTarget
112     */
113    public ItemShippingTarget buildUnchecked() {
114        return new ItemShippingTargetImpl(addressKey, quantity, shippingMethodKey);
115    }
116
117    /**
118     * factory method for an instance of ItemShippingTargetBuilder
119     * @return builder
120     */
121    public static ItemShippingTargetBuilder of() {
122        return new ItemShippingTargetBuilder();
123    }
124
125    /**
126     * create builder for ItemShippingTarget instance
127     * @param template instance with prefilled values for the builder
128     * @return builder
129     */
130    public static ItemShippingTargetBuilder of(final ItemShippingTarget template) {
131        ItemShippingTargetBuilder builder = new ItemShippingTargetBuilder();
132        builder.addressKey = template.getAddressKey();
133        builder.quantity = template.getQuantity();
134        builder.shippingMethodKey = template.getShippingMethodKey();
135        return builder;
136    }
137
138}