001
002package com.commercetools.api.models.cart_discount;
003
004import java.util.*;
005import java.util.function.Function;
006
007import io.vrap.rmf.base.client.Builder;
008import io.vrap.rmf.base.client.utils.Generated;
009
010/**
011 * CartDiscountValueFixedDraftBuilder
012 * <hr>
013 * Example to create an instance using the builder pattern
014 * <div class=code-example>
015 * <pre><code class='java'>
016 *     CartDiscountValueFixedDraft cartDiscountValueFixedDraft = CartDiscountValueFixedDraft.builder()
017 *             .plusMoney(moneyBuilder -> moneyBuilder)
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 CartDiscountValueFixedDraftBuilder implements Builder<CartDiscountValueFixedDraft> {
024
025    private java.util.List<com.commercetools.api.models.common.Money> money;
026
027    /**
028     *  <p>Money values in different currencies. A fixed Cart Discount will only match a price if this array contains a value with the same currency. If it contains 10&euro; and 15$, the matching &euro; price will be discounted by 10&euro; and the matching $ price will be discounted to 15$.</p>
029     * @param money value to be set
030     * @return Builder
031     */
032
033    public CartDiscountValueFixedDraftBuilder money(final com.commercetools.api.models.common.Money... money) {
034        this.money = new ArrayList<>(Arrays.asList(money));
035        return this;
036    }
037
038    /**
039     *  <p>Money values in different currencies. A fixed Cart Discount will only match a price if this array contains a value with the same currency. If it contains 10&euro; and 15$, the matching &euro; price will be discounted by 10&euro; and the matching $ price will be discounted to 15$.</p>
040     * @param money value to be set
041     * @return Builder
042     */
043
044    public CartDiscountValueFixedDraftBuilder money(
045            final java.util.List<com.commercetools.api.models.common.Money> money) {
046        this.money = money;
047        return this;
048    }
049
050    /**
051     *  <p>Money values in different currencies. A fixed Cart Discount will only match a price if this array contains a value with the same currency. If it contains 10&euro; and 15$, the matching &euro; price will be discounted by 10&euro; and the matching $ price will be discounted to 15$.</p>
052     * @param money value to be set
053     * @return Builder
054     */
055
056    public CartDiscountValueFixedDraftBuilder plusMoney(final com.commercetools.api.models.common.Money... money) {
057        if (this.money == null) {
058            this.money = new ArrayList<>();
059        }
060        this.money.addAll(Arrays.asList(money));
061        return this;
062    }
063
064    /**
065     *  <p>Money values in different currencies. A fixed Cart Discount will only match a price if this array contains a value with the same currency. If it contains 10&euro; and 15$, the matching &euro; price will be discounted by 10&euro; and the matching $ price will be discounted to 15$.</p>
066     * @param builder function to build the money value
067     * @return Builder
068     */
069
070    public CartDiscountValueFixedDraftBuilder plusMoney(
071            Function<com.commercetools.api.models.common.MoneyBuilder, com.commercetools.api.models.common.MoneyBuilder> builder) {
072        if (this.money == null) {
073            this.money = new ArrayList<>();
074        }
075        this.money.add(builder.apply(com.commercetools.api.models.common.MoneyBuilder.of()).build());
076        return this;
077    }
078
079    /**
080     *  <p>Money values in different currencies. A fixed Cart Discount will only match a price if this array contains a value with the same currency. If it contains 10&euro; and 15$, the matching &euro; price will be discounted by 10&euro; and the matching $ price will be discounted to 15$.</p>
081     * @param builder function to build the money value
082     * @return Builder
083     */
084
085    public CartDiscountValueFixedDraftBuilder withMoney(
086            Function<com.commercetools.api.models.common.MoneyBuilder, com.commercetools.api.models.common.MoneyBuilder> builder) {
087        this.money = new ArrayList<>();
088        this.money.add(builder.apply(com.commercetools.api.models.common.MoneyBuilder.of()).build());
089        return this;
090    }
091
092    /**
093     *  <p>Money values in different currencies. A fixed Cart Discount will only match a price if this array contains a value with the same currency. If it contains 10&euro; and 15$, the matching &euro; price will be discounted by 10&euro; and the matching $ price will be discounted to 15$.</p>
094     * @param builder function to build the money value
095     * @return Builder
096     */
097
098    public CartDiscountValueFixedDraftBuilder addMoney(
099            Function<com.commercetools.api.models.common.MoneyBuilder, com.commercetools.api.models.common.Money> builder) {
100        return plusMoney(builder.apply(com.commercetools.api.models.common.MoneyBuilder.of()));
101    }
102
103    /**
104     *  <p>Money values in different currencies. A fixed Cart Discount will only match a price if this array contains a value with the same currency. If it contains 10&euro; and 15$, the matching &euro; price will be discounted by 10&euro; and the matching $ price will be discounted to 15$.</p>
105     * @param builder function to build the money value
106     * @return Builder
107     */
108
109    public CartDiscountValueFixedDraftBuilder setMoney(
110            Function<com.commercetools.api.models.common.MoneyBuilder, com.commercetools.api.models.common.Money> builder) {
111        return money(builder.apply(com.commercetools.api.models.common.MoneyBuilder.of()));
112    }
113
114    /**
115     *  <p>Money values in different currencies. A fixed Cart Discount will only match a price if this array contains a value with the same currency. If it contains 10&euro; and 15$, the matching &euro; price will be discounted by 10&euro; and the matching $ price will be discounted to 15$.</p>
116     * @return money
117     */
118
119    public java.util.List<com.commercetools.api.models.common.Money> getMoney() {
120        return this.money;
121    }
122
123    /**
124     * builds CartDiscountValueFixedDraft with checking for non-null required values
125     * @return CartDiscountValueFixedDraft
126     */
127    public CartDiscountValueFixedDraft build() {
128        Objects.requireNonNull(money, CartDiscountValueFixedDraft.class + ": money is missing");
129        return new CartDiscountValueFixedDraftImpl(money);
130    }
131
132    /**
133     * builds CartDiscountValueFixedDraft without checking for non-null required values
134     * @return CartDiscountValueFixedDraft
135     */
136    public CartDiscountValueFixedDraft buildUnchecked() {
137        return new CartDiscountValueFixedDraftImpl(money);
138    }
139
140    /**
141     * factory method for an instance of CartDiscountValueFixedDraftBuilder
142     * @return builder
143     */
144    public static CartDiscountValueFixedDraftBuilder of() {
145        return new CartDiscountValueFixedDraftBuilder();
146    }
147
148    /**
149     * create builder for CartDiscountValueFixedDraft instance
150     * @param template instance with prefilled values for the builder
151     * @return builder
152     */
153    public static CartDiscountValueFixedDraftBuilder of(final CartDiscountValueFixedDraft template) {
154        CartDiscountValueFixedDraftBuilder builder = new CartDiscountValueFixedDraftBuilder();
155        builder.money = template.getMoney();
156        return builder;
157    }
158
159}