001
002package com.commercetools.api.models.quote_request;
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 * QuoteRequestDraftBuilder
014 * <hr>
015 * Example to create an instance using the builder pattern
016 * <div class=code-example>
017 * <pre><code class='java'>
018 *     QuoteRequestDraft quoteRequestDraft = QuoteRequestDraft.builder()
019 *             .cart(cartBuilder -> cartBuilder)
020 *             .cartVersion(0.3)
021 *             .comment("{comment}")
022 *             .build()
023 * </code></pre>
024 * </div>
025 */
026@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen")
027public class QuoteRequestDraftBuilder implements Builder<QuoteRequestDraft> {
028
029    private com.commercetools.api.models.cart.CartResourceIdentifier cart;
030
031    private Long cartVersion;
032
033    @Nullable
034    private String key;
035
036    private String comment;
037
038    @Nullable
039    private com.commercetools.api.models.type.CustomFieldsDraft custom;
040
041    @Nullable
042    private com.commercetools.api.models.state.StateReference state;
043
044    @Nullable
045    private String purchaseOrderNumber;
046
047    /**
048     *  <p>Cart for which a Quote is requested. Anonymous Carts, Carts with Discount Codes, or Carts with a <code>Multiple</code> ShippingMode are not supported.</p>
049     * @param builder function to build the cart value
050     * @return Builder
051     */
052
053    public QuoteRequestDraftBuilder cart(
054            Function<com.commercetools.api.models.cart.CartResourceIdentifierBuilder, com.commercetools.api.models.cart.CartResourceIdentifierBuilder> builder) {
055        this.cart = builder.apply(com.commercetools.api.models.cart.CartResourceIdentifierBuilder.of()).build();
056        return this;
057    }
058
059    /**
060     *  <p>Cart for which a Quote is requested. Anonymous Carts, Carts with Discount Codes, or Carts with a <code>Multiple</code> ShippingMode are not supported.</p>
061     * @param builder function to build the cart value
062     * @return Builder
063     */
064
065    public QuoteRequestDraftBuilder withCart(
066            Function<com.commercetools.api.models.cart.CartResourceIdentifierBuilder, com.commercetools.api.models.cart.CartResourceIdentifier> builder) {
067        this.cart = builder.apply(com.commercetools.api.models.cart.CartResourceIdentifierBuilder.of());
068        return this;
069    }
070
071    /**
072     *  <p>Cart for which a Quote is requested. Anonymous Carts, Carts with Discount Codes, or Carts with a <code>Multiple</code> ShippingMode are not supported.</p>
073     * @param cart value to be set
074     * @return Builder
075     */
076
077    public QuoteRequestDraftBuilder cart(final com.commercetools.api.models.cart.CartResourceIdentifier cart) {
078        this.cart = cart;
079        return this;
080    }
081
082    /**
083     *  <p>Current version of the referenced Cart.</p>
084     * @param cartVersion value to be set
085     * @return Builder
086     */
087
088    public QuoteRequestDraftBuilder cartVersion(final Long cartVersion) {
089        this.cartVersion = cartVersion;
090        return this;
091    }
092
093    /**
094     *  <p>User-defined unique identifier for the QuoteRequest.</p>
095     * @param key value to be set
096     * @return Builder
097     */
098
099    public QuoteRequestDraftBuilder key(@Nullable final String key) {
100        this.key = key;
101        return this;
102    }
103
104    /**
105     *  <p>Message from the Buyer included in the Quote Request.</p>
106     * @param comment value to be set
107     * @return Builder
108     */
109
110    public QuoteRequestDraftBuilder comment(final String comment) {
111        this.comment = comment;
112        return this;
113    }
114
115    /**
116     *  <p>Custom Fields to be added to the Quote Request.</p>
117     * @param builder function to build the custom value
118     * @return Builder
119     */
120
121    public QuoteRequestDraftBuilder custom(
122            Function<com.commercetools.api.models.type.CustomFieldsDraftBuilder, com.commercetools.api.models.type.CustomFieldsDraftBuilder> builder) {
123        this.custom = builder.apply(com.commercetools.api.models.type.CustomFieldsDraftBuilder.of()).build();
124        return this;
125    }
126
127    /**
128     *  <p>Custom Fields to be added to the Quote Request.</p>
129     * @param builder function to build the custom value
130     * @return Builder
131     */
132
133    public QuoteRequestDraftBuilder withCustom(
134            Function<com.commercetools.api.models.type.CustomFieldsDraftBuilder, com.commercetools.api.models.type.CustomFieldsDraft> builder) {
135        this.custom = builder.apply(com.commercetools.api.models.type.CustomFieldsDraftBuilder.of());
136        return this;
137    }
138
139    /**
140     *  <p>Custom Fields to be added to the Quote Request.</p>
141     * @param custom value to be set
142     * @return Builder
143     */
144
145    public QuoteRequestDraftBuilder custom(@Nullable final com.commercetools.api.models.type.CustomFieldsDraft custom) {
146        this.custom = custom;
147        return this;
148    }
149
150    /**
151     *  <p>State of the Quote Request. This reference can point to a State in a custom workflow.</p>
152     * @param builder function to build the state value
153     * @return Builder
154     */
155
156    public QuoteRequestDraftBuilder state(
157            Function<com.commercetools.api.models.state.StateReferenceBuilder, com.commercetools.api.models.state.StateReferenceBuilder> builder) {
158        this.state = builder.apply(com.commercetools.api.models.state.StateReferenceBuilder.of()).build();
159        return this;
160    }
161
162    /**
163     *  <p>State of the Quote Request. This reference can point to a State in a custom workflow.</p>
164     * @param builder function to build the state value
165     * @return Builder
166     */
167
168    public QuoteRequestDraftBuilder withState(
169            Function<com.commercetools.api.models.state.StateReferenceBuilder, com.commercetools.api.models.state.StateReference> builder) {
170        this.state = builder.apply(com.commercetools.api.models.state.StateReferenceBuilder.of());
171        return this;
172    }
173
174    /**
175     *  <p>State of the Quote Request. This reference can point to a State in a custom workflow.</p>
176     * @param state value to be set
177     * @return Builder
178     */
179
180    public QuoteRequestDraftBuilder state(@Nullable final com.commercetools.api.models.state.StateReference state) {
181        this.state = state;
182        return this;
183    }
184
185    /**
186     *  <p>Identifier for a purchase order, usually in a B2B context. The Purchase Order Number is typically entered by the Buyer.</p>
187     * @param purchaseOrderNumber value to be set
188     * @return Builder
189     */
190
191    public QuoteRequestDraftBuilder purchaseOrderNumber(@Nullable final String purchaseOrderNumber) {
192        this.purchaseOrderNumber = purchaseOrderNumber;
193        return this;
194    }
195
196    /**
197     *  <p>Cart for which a Quote is requested. Anonymous Carts, Carts with Discount Codes, or Carts with a <code>Multiple</code> ShippingMode are not supported.</p>
198     * @return cart
199     */
200
201    public com.commercetools.api.models.cart.CartResourceIdentifier getCart() {
202        return this.cart;
203    }
204
205    /**
206     *  <p>Current version of the referenced Cart.</p>
207     * @return cartVersion
208     */
209
210    public Long getCartVersion() {
211        return this.cartVersion;
212    }
213
214    /**
215     *  <p>User-defined unique identifier for the QuoteRequest.</p>
216     * @return key
217     */
218
219    @Nullable
220    public String getKey() {
221        return this.key;
222    }
223
224    /**
225     *  <p>Message from the Buyer included in the Quote Request.</p>
226     * @return comment
227     */
228
229    public String getComment() {
230        return this.comment;
231    }
232
233    /**
234     *  <p>Custom Fields to be added to the Quote Request.</p>
235     * @return custom
236     */
237
238    @Nullable
239    public com.commercetools.api.models.type.CustomFieldsDraft getCustom() {
240        return this.custom;
241    }
242
243    /**
244     *  <p>State of the Quote Request. This reference can point to a State in a custom workflow.</p>
245     * @return state
246     */
247
248    @Nullable
249    public com.commercetools.api.models.state.StateReference getState() {
250        return this.state;
251    }
252
253    /**
254     *  <p>Identifier for a purchase order, usually in a B2B context. The Purchase Order Number is typically entered by the Buyer.</p>
255     * @return purchaseOrderNumber
256     */
257
258    @Nullable
259    public String getPurchaseOrderNumber() {
260        return this.purchaseOrderNumber;
261    }
262
263    /**
264     * builds QuoteRequestDraft with checking for non-null required values
265     * @return QuoteRequestDraft
266     */
267    public QuoteRequestDraft build() {
268        Objects.requireNonNull(cart, QuoteRequestDraft.class + ": cart is missing");
269        Objects.requireNonNull(cartVersion, QuoteRequestDraft.class + ": cartVersion is missing");
270        Objects.requireNonNull(comment, QuoteRequestDraft.class + ": comment is missing");
271        return new QuoteRequestDraftImpl(cart, cartVersion, key, comment, custom, state, purchaseOrderNumber);
272    }
273
274    /**
275     * builds QuoteRequestDraft without checking for non-null required values
276     * @return QuoteRequestDraft
277     */
278    public QuoteRequestDraft buildUnchecked() {
279        return new QuoteRequestDraftImpl(cart, cartVersion, key, comment, custom, state, purchaseOrderNumber);
280    }
281
282    /**
283     * factory method for an instance of QuoteRequestDraftBuilder
284     * @return builder
285     */
286    public static QuoteRequestDraftBuilder of() {
287        return new QuoteRequestDraftBuilder();
288    }
289
290    /**
291     * create builder for QuoteRequestDraft instance
292     * @param template instance with prefilled values for the builder
293     * @return builder
294     */
295    public static QuoteRequestDraftBuilder of(final QuoteRequestDraft template) {
296        QuoteRequestDraftBuilder builder = new QuoteRequestDraftBuilder();
297        builder.cart = template.getCart();
298        builder.cartVersion = template.getCartVersion();
299        builder.key = template.getKey();
300        builder.comment = template.getComment();
301        builder.custom = template.getCustom();
302        builder.state = template.getState();
303        builder.purchaseOrderNumber = template.getPurchaseOrderNumber();
304        return builder;
305    }
306
307}