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 * ShippingDraftBuilder
014 * <hr>
015 * Example to create an instance using the builder pattern
016 * <div class=code-example>
017 * <pre><code class='java'>
018 *     ShippingDraft shippingDraft = ShippingDraft.builder()
019 *             .key("{key}")
020 *             .shippingAddress(shippingAddressBuilder -> shippingAddressBuilder)
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 ShippingDraftBuilder implements Builder<ShippingDraft> {
027
028    private String key;
029
030    @Nullable
031    private com.commercetools.api.models.shipping_method.ShippingMethodReference shippingMethod;
032
033    private com.commercetools.api.models.common.BaseAddress shippingAddress;
034
035    @Nullable
036    private com.commercetools.api.models.cart.ShippingRateInputDraft shippingRateInput;
037
038    @Nullable
039    private com.commercetools.api.models.cart.ExternalTaxRateDraft externalTaxRate;
040
041    @Nullable
042    private java.util.List<com.commercetools.api.models.order.DeliveryDraft> deliveries;
043
044    @Nullable
045    private com.commercetools.api.models.type.CustomFieldsDraft custom;
046
047    /**
048     *  <p>User-defined unique identifier for the Shipping in a Cart with <code>Multiple</code> ShippingMode.</p>
049     * @param key value to be set
050     * @return Builder
051     */
052
053    public ShippingDraftBuilder key(final String key) {
054        this.key = key;
055        return this;
056    }
057
058    /**
059     *  <p>Shipping Methods added to the Cart with <code>Multiple</code> ShippingMode.</p>
060     * @param builder function to build the shippingMethod value
061     * @return Builder
062     */
063
064    public ShippingDraftBuilder shippingMethod(
065            Function<com.commercetools.api.models.shipping_method.ShippingMethodReferenceBuilder, com.commercetools.api.models.shipping_method.ShippingMethodReferenceBuilder> builder) {
066        this.shippingMethod = builder
067                .apply(com.commercetools.api.models.shipping_method.ShippingMethodReferenceBuilder.of())
068                .build();
069        return this;
070    }
071
072    /**
073     *  <p>Shipping Methods added to the Cart with <code>Multiple</code> ShippingMode.</p>
074     * @param builder function to build the shippingMethod value
075     * @return Builder
076     */
077
078    public ShippingDraftBuilder withShippingMethod(
079            Function<com.commercetools.api.models.shipping_method.ShippingMethodReferenceBuilder, com.commercetools.api.models.shipping_method.ShippingMethodReference> builder) {
080        this.shippingMethod = builder
081                .apply(com.commercetools.api.models.shipping_method.ShippingMethodReferenceBuilder.of());
082        return this;
083    }
084
085    /**
086     *  <p>Shipping Methods added to the Cart with <code>Multiple</code> ShippingMode.</p>
087     * @param shippingMethod value to be set
088     * @return Builder
089     */
090
091    public ShippingDraftBuilder shippingMethod(
092            @Nullable final com.commercetools.api.models.shipping_method.ShippingMethodReference shippingMethod) {
093        this.shippingMethod = shippingMethod;
094        return this;
095    }
096
097    /**
098     *  <p>Determines the shipping rate and Tax Rate of the associated Line Items.</p>
099     * @param builder function to build the shippingAddress value
100     * @return Builder
101     */
102
103    public ShippingDraftBuilder shippingAddress(
104            Function<com.commercetools.api.models.common.BaseAddressBuilder, com.commercetools.api.models.common.BaseAddressBuilder> builder) {
105        this.shippingAddress = builder.apply(com.commercetools.api.models.common.BaseAddressBuilder.of()).build();
106        return this;
107    }
108
109    /**
110     *  <p>Determines the shipping rate and Tax Rate of the associated Line Items.</p>
111     * @param builder function to build the shippingAddress value
112     * @return Builder
113     */
114
115    public ShippingDraftBuilder withShippingAddress(
116            Function<com.commercetools.api.models.common.BaseAddressBuilder, com.commercetools.api.models.common.BaseAddress> builder) {
117        this.shippingAddress = builder.apply(com.commercetools.api.models.common.BaseAddressBuilder.of());
118        return this;
119    }
120
121    /**
122     *  <p>Determines the shipping rate and Tax Rate of the associated Line Items.</p>
123     * @param shippingAddress value to be set
124     * @return Builder
125     */
126
127    public ShippingDraftBuilder shippingAddress(final com.commercetools.api.models.common.BaseAddress shippingAddress) {
128        this.shippingAddress = shippingAddress;
129        return this;
130    }
131
132    /**
133     *  <p>Input used to select a ShippingRatePriceTier. The data type of this field depends on the <code>shippingRateInputType.type</code> configured in the Project:</p>
134     *  <ul>
135     *   <li>If <code>CartClassification</code>, it must be ClassificationShippingRateInputDraft.</li>
136     *   <li>If <code>CartScore</code>, it must be ScoreShippingRateInputDraft.</li>
137     *   <li>If <code>CartValue</code>, it cannot be set.</li>
138     *  </ul>
139     * @param shippingRateInput value to be set
140     * @return Builder
141     */
142
143    public ShippingDraftBuilder shippingRateInput(
144            @Nullable final com.commercetools.api.models.cart.ShippingRateInputDraft shippingRateInput) {
145        this.shippingRateInput = shippingRateInput;
146        return this;
147    }
148
149    /**
150     *  <p>Input used to select a ShippingRatePriceTier. The data type of this field depends on the <code>shippingRateInputType.type</code> configured in the Project:</p>
151     *  <ul>
152     *   <li>If <code>CartClassification</code>, it must be ClassificationShippingRateInputDraft.</li>
153     *   <li>If <code>CartScore</code>, it must be ScoreShippingRateInputDraft.</li>
154     *   <li>If <code>CartValue</code>, it cannot be set.</li>
155     *  </ul>
156     * @param builder function to build the shippingRateInput value
157     * @return Builder
158     */
159
160    public ShippingDraftBuilder shippingRateInput(
161            Function<com.commercetools.api.models.cart.ShippingRateInputDraftBuilder, Builder<? extends com.commercetools.api.models.cart.ShippingRateInputDraft>> builder) {
162        this.shippingRateInput = builder.apply(com.commercetools.api.models.cart.ShippingRateInputDraftBuilder.of())
163                .build();
164        return this;
165    }
166
167    /**
168     *  <p>Tax Rate used for taxing a shipping expense if the Cart has the <code>External</code> TaxMode.</p>
169     * @param builder function to build the externalTaxRate value
170     * @return Builder
171     */
172
173    public ShippingDraftBuilder externalTaxRate(
174            Function<com.commercetools.api.models.cart.ExternalTaxRateDraftBuilder, com.commercetools.api.models.cart.ExternalTaxRateDraftBuilder> builder) {
175        this.externalTaxRate = builder.apply(com.commercetools.api.models.cart.ExternalTaxRateDraftBuilder.of())
176                .build();
177        return this;
178    }
179
180    /**
181     *  <p>Tax Rate used for taxing a shipping expense if the Cart has the <code>External</code> TaxMode.</p>
182     * @param builder function to build the externalTaxRate value
183     * @return Builder
184     */
185
186    public ShippingDraftBuilder withExternalTaxRate(
187            Function<com.commercetools.api.models.cart.ExternalTaxRateDraftBuilder, com.commercetools.api.models.cart.ExternalTaxRateDraft> builder) {
188        this.externalTaxRate = builder.apply(com.commercetools.api.models.cart.ExternalTaxRateDraftBuilder.of());
189        return this;
190    }
191
192    /**
193     *  <p>Tax Rate used for taxing a shipping expense if the Cart has the <code>External</code> TaxMode.</p>
194     * @param externalTaxRate value to be set
195     * @return Builder
196     */
197
198    public ShippingDraftBuilder externalTaxRate(
199            @Nullable final com.commercetools.api.models.cart.ExternalTaxRateDraft externalTaxRate) {
200        this.externalTaxRate = externalTaxRate;
201        return this;
202    }
203
204    /**
205     *  <p>Deliveries to be shipped with the Shipping Method.</p>
206     * @param deliveries value to be set
207     * @return Builder
208     */
209
210    public ShippingDraftBuilder deliveries(
211            @Nullable final com.commercetools.api.models.order.DeliveryDraft... deliveries) {
212        this.deliveries = new ArrayList<>(Arrays.asList(deliveries));
213        return this;
214    }
215
216    /**
217     *  <p>Deliveries to be shipped with the Shipping Method.</p>
218     * @param deliveries value to be set
219     * @return Builder
220     */
221
222    public ShippingDraftBuilder deliveries(
223            @Nullable final java.util.List<com.commercetools.api.models.order.DeliveryDraft> deliveries) {
224        this.deliveries = deliveries;
225        return this;
226    }
227
228    /**
229     *  <p>Deliveries to be shipped with the Shipping Method.</p>
230     * @param deliveries value to be set
231     * @return Builder
232     */
233
234    public ShippingDraftBuilder plusDeliveries(
235            @Nullable final com.commercetools.api.models.order.DeliveryDraft... deliveries) {
236        if (this.deliveries == null) {
237            this.deliveries = new ArrayList<>();
238        }
239        this.deliveries.addAll(Arrays.asList(deliveries));
240        return this;
241    }
242
243    /**
244     *  <p>Deliveries to be shipped with the Shipping Method.</p>
245     * @param builder function to build the deliveries value
246     * @return Builder
247     */
248
249    public ShippingDraftBuilder plusDeliveries(
250            Function<com.commercetools.api.models.order.DeliveryDraftBuilder, com.commercetools.api.models.order.DeliveryDraftBuilder> builder) {
251        if (this.deliveries == null) {
252            this.deliveries = new ArrayList<>();
253        }
254        this.deliveries.add(builder.apply(com.commercetools.api.models.order.DeliveryDraftBuilder.of()).build());
255        return this;
256    }
257
258    /**
259     *  <p>Deliveries to be shipped with the Shipping Method.</p>
260     * @param builder function to build the deliveries value
261     * @return Builder
262     */
263
264    public ShippingDraftBuilder withDeliveries(
265            Function<com.commercetools.api.models.order.DeliveryDraftBuilder, com.commercetools.api.models.order.DeliveryDraftBuilder> builder) {
266        this.deliveries = new ArrayList<>();
267        this.deliveries.add(builder.apply(com.commercetools.api.models.order.DeliveryDraftBuilder.of()).build());
268        return this;
269    }
270
271    /**
272     *  <p>Deliveries to be shipped with the Shipping Method.</p>
273     * @param builder function to build the deliveries value
274     * @return Builder
275     */
276
277    public ShippingDraftBuilder addDeliveries(
278            Function<com.commercetools.api.models.order.DeliveryDraftBuilder, com.commercetools.api.models.order.DeliveryDraft> builder) {
279        return plusDeliveries(builder.apply(com.commercetools.api.models.order.DeliveryDraftBuilder.of()));
280    }
281
282    /**
283     *  <p>Deliveries to be shipped with the Shipping Method.</p>
284     * @param builder function to build the deliveries value
285     * @return Builder
286     */
287
288    public ShippingDraftBuilder setDeliveries(
289            Function<com.commercetools.api.models.order.DeliveryDraftBuilder, com.commercetools.api.models.order.DeliveryDraft> builder) {
290        return deliveries(builder.apply(com.commercetools.api.models.order.DeliveryDraftBuilder.of()));
291    }
292
293    /**
294     *  <p>Custom Fields for Shipping.</p>
295     * @param builder function to build the custom value
296     * @return Builder
297     */
298
299    public ShippingDraftBuilder custom(
300            Function<com.commercetools.api.models.type.CustomFieldsDraftBuilder, com.commercetools.api.models.type.CustomFieldsDraftBuilder> builder) {
301        this.custom = builder.apply(com.commercetools.api.models.type.CustomFieldsDraftBuilder.of()).build();
302        return this;
303    }
304
305    /**
306     *  <p>Custom Fields for Shipping.</p>
307     * @param builder function to build the custom value
308     * @return Builder
309     */
310
311    public ShippingDraftBuilder withCustom(
312            Function<com.commercetools.api.models.type.CustomFieldsDraftBuilder, com.commercetools.api.models.type.CustomFieldsDraft> builder) {
313        this.custom = builder.apply(com.commercetools.api.models.type.CustomFieldsDraftBuilder.of());
314        return this;
315    }
316
317    /**
318     *  <p>Custom Fields for Shipping.</p>
319     * @param custom value to be set
320     * @return Builder
321     */
322
323    public ShippingDraftBuilder custom(@Nullable final com.commercetools.api.models.type.CustomFieldsDraft custom) {
324        this.custom = custom;
325        return this;
326    }
327
328    /**
329     *  <p>User-defined unique identifier for the Shipping in a Cart with <code>Multiple</code> ShippingMode.</p>
330     * @return key
331     */
332
333    public String getKey() {
334        return this.key;
335    }
336
337    /**
338     *  <p>Shipping Methods added to the Cart with <code>Multiple</code> ShippingMode.</p>
339     * @return shippingMethod
340     */
341
342    @Nullable
343    public com.commercetools.api.models.shipping_method.ShippingMethodReference getShippingMethod() {
344        return this.shippingMethod;
345    }
346
347    /**
348     *  <p>Determines the shipping rate and Tax Rate of the associated Line Items.</p>
349     * @return shippingAddress
350     */
351
352    public com.commercetools.api.models.common.BaseAddress getShippingAddress() {
353        return this.shippingAddress;
354    }
355
356    /**
357     *  <p>Input used to select a ShippingRatePriceTier. The data type of this field depends on the <code>shippingRateInputType.type</code> configured in the Project:</p>
358     *  <ul>
359     *   <li>If <code>CartClassification</code>, it must be ClassificationShippingRateInputDraft.</li>
360     *   <li>If <code>CartScore</code>, it must be ScoreShippingRateInputDraft.</li>
361     *   <li>If <code>CartValue</code>, it cannot be set.</li>
362     *  </ul>
363     * @return shippingRateInput
364     */
365
366    @Nullable
367    public com.commercetools.api.models.cart.ShippingRateInputDraft getShippingRateInput() {
368        return this.shippingRateInput;
369    }
370
371    /**
372     *  <p>Tax Rate used for taxing a shipping expense if the Cart has the <code>External</code> TaxMode.</p>
373     * @return externalTaxRate
374     */
375
376    @Nullable
377    public com.commercetools.api.models.cart.ExternalTaxRateDraft getExternalTaxRate() {
378        return this.externalTaxRate;
379    }
380
381    /**
382     *  <p>Deliveries to be shipped with the Shipping Method.</p>
383     * @return deliveries
384     */
385
386    @Nullable
387    public java.util.List<com.commercetools.api.models.order.DeliveryDraft> getDeliveries() {
388        return this.deliveries;
389    }
390
391    /**
392     *  <p>Custom Fields for Shipping.</p>
393     * @return custom
394     */
395
396    @Nullable
397    public com.commercetools.api.models.type.CustomFieldsDraft getCustom() {
398        return this.custom;
399    }
400
401    /**
402     * builds ShippingDraft with checking for non-null required values
403     * @return ShippingDraft
404     */
405    public ShippingDraft build() {
406        Objects.requireNonNull(key, ShippingDraft.class + ": key is missing");
407        Objects.requireNonNull(shippingAddress, ShippingDraft.class + ": shippingAddress is missing");
408        return new ShippingDraftImpl(key, shippingMethod, shippingAddress, shippingRateInput, externalTaxRate,
409            deliveries, custom);
410    }
411
412    /**
413     * builds ShippingDraft without checking for non-null required values
414     * @return ShippingDraft
415     */
416    public ShippingDraft buildUnchecked() {
417        return new ShippingDraftImpl(key, shippingMethod, shippingAddress, shippingRateInput, externalTaxRate,
418            deliveries, custom);
419    }
420
421    /**
422     * factory method for an instance of ShippingDraftBuilder
423     * @return builder
424     */
425    public static ShippingDraftBuilder of() {
426        return new ShippingDraftBuilder();
427    }
428
429    /**
430     * create builder for ShippingDraft instance
431     * @param template instance with prefilled values for the builder
432     * @return builder
433     */
434    public static ShippingDraftBuilder of(final ShippingDraft template) {
435        ShippingDraftBuilder builder = new ShippingDraftBuilder();
436        builder.key = template.getKey();
437        builder.shippingMethod = template.getShippingMethod();
438        builder.shippingAddress = template.getShippingAddress();
439        builder.shippingRateInput = template.getShippingRateInput();
440        builder.externalTaxRate = template.getExternalTaxRate();
441        builder.deliveries = template.getDeliveries();
442        builder.custom = template.getCustom();
443        return builder;
444    }
445
446}