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