001
002package com.commercetools.api.models.cart;
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 * CartChangeLineItemQuantityActionBuilder
014 * <hr>
015 * Example to create an instance using the builder pattern
016 * <div class=code-example>
017 * <pre><code class='java'>
018 *     CartChangeLineItemQuantityAction cartChangeLineItemQuantityAction = CartChangeLineItemQuantityAction.builder()
019 *             .lineItemId("{lineItemId}")
020 *             .quantity(0.3)
021 *             .build()
022 * </code></pre>
023 * </div>
024 */
025@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen")
026public class CartChangeLineItemQuantityActionBuilder implements Builder<CartChangeLineItemQuantityAction> {
027
028    private String lineItemId;
029
030    private Long quantity;
031
032    @Nullable
033    private com.commercetools.api.models.common.Money externalPrice;
034
035    @Nullable
036    private com.commercetools.api.models.cart.ExternalLineItemTotalPrice externalTotalPrice;
037
038    /**
039     *  <p><code>id</code> of the LineItem to update.</p>
040     * @param lineItemId value to be set
041     * @return Builder
042     */
043
044    public CartChangeLineItemQuantityActionBuilder lineItemId(final String lineItemId) {
045        this.lineItemId = lineItemId;
046        return this;
047    }
048
049    /**
050     *  <p>New value to set.</p>
051     *  <p>If <code>0</code>, the Line Item is removed from the Cart.</p>
052     * @param quantity value to be set
053     * @return Builder
054     */
055
056    public CartChangeLineItemQuantityActionBuilder quantity(final Long quantity) {
057        this.quantity = quantity;
058        return this;
059    }
060
061    /**
062     *  <p>Sets the LineItem <code>price</code> to the given value when changing the quantity of a Line Item with the <code>ExternalPrice</code> LineItemPriceMode.</p>
063     *  <p>The LineItem price is updated as described in LineItem Price selection.</p>
064     * @param builder function to build the externalPrice value
065     * @return Builder
066     */
067
068    public CartChangeLineItemQuantityActionBuilder externalPrice(
069            Function<com.commercetools.api.models.common.MoneyBuilder, com.commercetools.api.models.common.MoneyBuilder> builder) {
070        this.externalPrice = builder.apply(com.commercetools.api.models.common.MoneyBuilder.of()).build();
071        return this;
072    }
073
074    /**
075     *  <p>Sets the LineItem <code>price</code> to the given value when changing the quantity of a Line Item with the <code>ExternalPrice</code> LineItemPriceMode.</p>
076     *  <p>The LineItem price is updated as described in LineItem Price selection.</p>
077     * @param builder function to build the externalPrice value
078     * @return Builder
079     */
080
081    public CartChangeLineItemQuantityActionBuilder withExternalPrice(
082            Function<com.commercetools.api.models.common.MoneyBuilder, com.commercetools.api.models.common.Money> builder) {
083        this.externalPrice = builder.apply(com.commercetools.api.models.common.MoneyBuilder.of());
084        return this;
085    }
086
087    /**
088     *  <p>Sets the LineItem <code>price</code> to the given value when changing the quantity of a Line Item with the <code>ExternalPrice</code> LineItemPriceMode.</p>
089     *  <p>The LineItem price is updated as described in LineItem Price selection.</p>
090     * @param externalPrice value to be set
091     * @return Builder
092     */
093
094    public CartChangeLineItemQuantityActionBuilder externalPrice(
095            @Nullable final com.commercetools.api.models.common.Money externalPrice) {
096        this.externalPrice = externalPrice;
097        return this;
098    }
099
100    /**
101     *  <p>Sets the LineItem <code>price</code> and <code>totalPrice</code> to the given value when changing the quantity of a Line Item with the <code>ExternalTotal</code> LineItemPriceMode.</p>
102     * @param builder function to build the externalTotalPrice value
103     * @return Builder
104     */
105
106    public CartChangeLineItemQuantityActionBuilder externalTotalPrice(
107            Function<com.commercetools.api.models.cart.ExternalLineItemTotalPriceBuilder, com.commercetools.api.models.cart.ExternalLineItemTotalPriceBuilder> builder) {
108        this.externalTotalPrice = builder
109                .apply(com.commercetools.api.models.cart.ExternalLineItemTotalPriceBuilder.of())
110                .build();
111        return this;
112    }
113
114    /**
115     *  <p>Sets the LineItem <code>price</code> and <code>totalPrice</code> to the given value when changing the quantity of a Line Item with the <code>ExternalTotal</code> LineItemPriceMode.</p>
116     * @param builder function to build the externalTotalPrice value
117     * @return Builder
118     */
119
120    public CartChangeLineItemQuantityActionBuilder withExternalTotalPrice(
121            Function<com.commercetools.api.models.cart.ExternalLineItemTotalPriceBuilder, com.commercetools.api.models.cart.ExternalLineItemTotalPrice> builder) {
122        this.externalTotalPrice = builder
123                .apply(com.commercetools.api.models.cart.ExternalLineItemTotalPriceBuilder.of());
124        return this;
125    }
126
127    /**
128     *  <p>Sets the LineItem <code>price</code> and <code>totalPrice</code> to the given value when changing the quantity of a Line Item with the <code>ExternalTotal</code> LineItemPriceMode.</p>
129     * @param externalTotalPrice value to be set
130     * @return Builder
131     */
132
133    public CartChangeLineItemQuantityActionBuilder externalTotalPrice(
134            @Nullable final com.commercetools.api.models.cart.ExternalLineItemTotalPrice externalTotalPrice) {
135        this.externalTotalPrice = externalTotalPrice;
136        return this;
137    }
138
139    /**
140     *  <p><code>id</code> of the LineItem to update.</p>
141     * @return lineItemId
142     */
143
144    public String getLineItemId() {
145        return this.lineItemId;
146    }
147
148    /**
149     *  <p>New value to set.</p>
150     *  <p>If <code>0</code>, the Line Item is removed from the Cart.</p>
151     * @return quantity
152     */
153
154    public Long getQuantity() {
155        return this.quantity;
156    }
157
158    /**
159     *  <p>Sets the LineItem <code>price</code> to the given value when changing the quantity of a Line Item with the <code>ExternalPrice</code> LineItemPriceMode.</p>
160     *  <p>The LineItem price is updated as described in LineItem Price selection.</p>
161     * @return externalPrice
162     */
163
164    @Nullable
165    public com.commercetools.api.models.common.Money getExternalPrice() {
166        return this.externalPrice;
167    }
168
169    /**
170     *  <p>Sets the LineItem <code>price</code> and <code>totalPrice</code> to the given value when changing the quantity of a Line Item with the <code>ExternalTotal</code> LineItemPriceMode.</p>
171     * @return externalTotalPrice
172     */
173
174    @Nullable
175    public com.commercetools.api.models.cart.ExternalLineItemTotalPrice getExternalTotalPrice() {
176        return this.externalTotalPrice;
177    }
178
179    /**
180     * builds CartChangeLineItemQuantityAction with checking for non-null required values
181     * @return CartChangeLineItemQuantityAction
182     */
183    public CartChangeLineItemQuantityAction build() {
184        Objects.requireNonNull(lineItemId, CartChangeLineItemQuantityAction.class + ": lineItemId is missing");
185        Objects.requireNonNull(quantity, CartChangeLineItemQuantityAction.class + ": quantity is missing");
186        return new CartChangeLineItemQuantityActionImpl(lineItemId, quantity, externalPrice, externalTotalPrice);
187    }
188
189    /**
190     * builds CartChangeLineItemQuantityAction without checking for non-null required values
191     * @return CartChangeLineItemQuantityAction
192     */
193    public CartChangeLineItemQuantityAction buildUnchecked() {
194        return new CartChangeLineItemQuantityActionImpl(lineItemId, quantity, externalPrice, externalTotalPrice);
195    }
196
197    /**
198     * factory method for an instance of CartChangeLineItemQuantityActionBuilder
199     * @return builder
200     */
201    public static CartChangeLineItemQuantityActionBuilder of() {
202        return new CartChangeLineItemQuantityActionBuilder();
203    }
204
205    /**
206     * create builder for CartChangeLineItemQuantityAction instance
207     * @param template instance with prefilled values for the builder
208     * @return builder
209     */
210    public static CartChangeLineItemQuantityActionBuilder of(final CartChangeLineItemQuantityAction template) {
211        CartChangeLineItemQuantityActionBuilder builder = new CartChangeLineItemQuantityActionBuilder();
212        builder.lineItemId = template.getLineItemId();
213        builder.quantity = template.getQuantity();
214        builder.externalPrice = template.getExternalPrice();
215        builder.externalTotalPrice = template.getExternalTotalPrice();
216        return builder;
217    }
218
219}