001
002package com.commercetools.history.models.common;
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 * DiscountedLineItemPriceBuilder
012 * <hr>
013 * Example to create an instance using the builder pattern
014 * <div class=code-example>
015 * <pre><code class='java'>
016 *     DiscountedLineItemPrice discountedLineItemPrice = DiscountedLineItemPrice.builder()
017 *             .value(valueBuilder -> valueBuilder)
018 *             .plusIncludedDiscounts(includedDiscountsBuilder -> includedDiscountsBuilder)
019 *             .build()
020 * </code></pre>
021 * </div>
022 */
023@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen")
024public class DiscountedLineItemPriceBuilder implements Builder<DiscountedLineItemPrice> {
025
026    private com.commercetools.history.models.common.Money value;
027
028    private java.util.List<com.commercetools.history.models.common.DiscountedLineItemPortion> includedDiscounts;
029
030    /**
031     * set the value to the value using the builder function
032     * @param builder function to build the value value
033     * @return Builder
034     */
035
036    public DiscountedLineItemPriceBuilder value(
037            Function<com.commercetools.history.models.common.MoneyBuilder, com.commercetools.history.models.common.MoneyBuilder> builder) {
038        this.value = builder.apply(com.commercetools.history.models.common.MoneyBuilder.of()).build();
039        return this;
040    }
041
042    /**
043     * set the value to the value using the builder function
044     * @param builder function to build the value value
045     * @return Builder
046     */
047
048    public DiscountedLineItemPriceBuilder withValue(
049            Function<com.commercetools.history.models.common.MoneyBuilder, com.commercetools.history.models.common.Money> builder) {
050        this.value = builder.apply(com.commercetools.history.models.common.MoneyBuilder.of());
051        return this;
052    }
053
054    /**
055     * set the value to the value
056     * @param value value to be set
057     * @return Builder
058     */
059
060    public DiscountedLineItemPriceBuilder value(final com.commercetools.history.models.common.Money value) {
061        this.value = value;
062        return this;
063    }
064
065    /**
066     * set values to the includedDiscounts
067     * @param includedDiscounts value to be set
068     * @return Builder
069     */
070
071    public DiscountedLineItemPriceBuilder includedDiscounts(
072            final com.commercetools.history.models.common.DiscountedLineItemPortion... includedDiscounts) {
073        this.includedDiscounts = new ArrayList<>(Arrays.asList(includedDiscounts));
074        return this;
075    }
076
077    /**
078     * set value to the includedDiscounts
079     * @param includedDiscounts value to be set
080     * @return Builder
081     */
082
083    public DiscountedLineItemPriceBuilder includedDiscounts(
084            final java.util.List<com.commercetools.history.models.common.DiscountedLineItemPortion> includedDiscounts) {
085        this.includedDiscounts = includedDiscounts;
086        return this;
087    }
088
089    /**
090     * add values to the includedDiscounts
091     * @param includedDiscounts value to be set
092     * @return Builder
093     */
094
095    public DiscountedLineItemPriceBuilder plusIncludedDiscounts(
096            final com.commercetools.history.models.common.DiscountedLineItemPortion... includedDiscounts) {
097        if (this.includedDiscounts == null) {
098            this.includedDiscounts = new ArrayList<>();
099        }
100        this.includedDiscounts.addAll(Arrays.asList(includedDiscounts));
101        return this;
102    }
103
104    /**
105     * add the value to the includedDiscounts using the builder function
106     * @param builder function to build the includedDiscounts value
107     * @return Builder
108     */
109
110    public DiscountedLineItemPriceBuilder plusIncludedDiscounts(
111            Function<com.commercetools.history.models.common.DiscountedLineItemPortionBuilder, com.commercetools.history.models.common.DiscountedLineItemPortionBuilder> builder) {
112        if (this.includedDiscounts == null) {
113            this.includedDiscounts = new ArrayList<>();
114        }
115        this.includedDiscounts.add(
116            builder.apply(com.commercetools.history.models.common.DiscountedLineItemPortionBuilder.of()).build());
117        return this;
118    }
119
120    /**
121     * set the value to the includedDiscounts using the builder function
122     * @param builder function to build the includedDiscounts value
123     * @return Builder
124     */
125
126    public DiscountedLineItemPriceBuilder withIncludedDiscounts(
127            Function<com.commercetools.history.models.common.DiscountedLineItemPortionBuilder, com.commercetools.history.models.common.DiscountedLineItemPortionBuilder> builder) {
128        this.includedDiscounts = new ArrayList<>();
129        this.includedDiscounts.add(
130            builder.apply(com.commercetools.history.models.common.DiscountedLineItemPortionBuilder.of()).build());
131        return this;
132    }
133
134    /**
135     * add the value to the includedDiscounts using the builder function
136     * @param builder function to build the includedDiscounts value
137     * @return Builder
138     */
139
140    public DiscountedLineItemPriceBuilder addIncludedDiscounts(
141            Function<com.commercetools.history.models.common.DiscountedLineItemPortionBuilder, com.commercetools.history.models.common.DiscountedLineItemPortion> builder) {
142        return plusIncludedDiscounts(
143            builder.apply(com.commercetools.history.models.common.DiscountedLineItemPortionBuilder.of()));
144    }
145
146    /**
147     * set the value to the includedDiscounts using the builder function
148     * @param builder function to build the includedDiscounts value
149     * @return Builder
150     */
151
152    public DiscountedLineItemPriceBuilder setIncludedDiscounts(
153            Function<com.commercetools.history.models.common.DiscountedLineItemPortionBuilder, com.commercetools.history.models.common.DiscountedLineItemPortion> builder) {
154        return includedDiscounts(
155            builder.apply(com.commercetools.history.models.common.DiscountedLineItemPortionBuilder.of()));
156    }
157
158    /**
159     * value of value}
160     * @return value
161     */
162
163    public com.commercetools.history.models.common.Money getValue() {
164        return this.value;
165    }
166
167    /**
168     * value of includedDiscounts}
169     * @return includedDiscounts
170     */
171
172    public java.util.List<com.commercetools.history.models.common.DiscountedLineItemPortion> getIncludedDiscounts() {
173        return this.includedDiscounts;
174    }
175
176    /**
177     * builds DiscountedLineItemPrice with checking for non-null required values
178     * @return DiscountedLineItemPrice
179     */
180    public DiscountedLineItemPrice build() {
181        Objects.requireNonNull(value, DiscountedLineItemPrice.class + ": value is missing");
182        Objects.requireNonNull(includedDiscounts, DiscountedLineItemPrice.class + ": includedDiscounts is missing");
183        return new DiscountedLineItemPriceImpl(value, includedDiscounts);
184    }
185
186    /**
187     * builds DiscountedLineItemPrice without checking for non-null required values
188     * @return DiscountedLineItemPrice
189     */
190    public DiscountedLineItemPrice buildUnchecked() {
191        return new DiscountedLineItemPriceImpl(value, includedDiscounts);
192    }
193
194    /**
195     * factory method for an instance of DiscountedLineItemPriceBuilder
196     * @return builder
197     */
198    public static DiscountedLineItemPriceBuilder of() {
199        return new DiscountedLineItemPriceBuilder();
200    }
201
202    /**
203     * create builder for DiscountedLineItemPrice instance
204     * @param template instance with prefilled values for the builder
205     * @return builder
206     */
207    public static DiscountedLineItemPriceBuilder of(final DiscountedLineItemPrice template) {
208        DiscountedLineItemPriceBuilder builder = new DiscountedLineItemPriceBuilder();
209        builder.value = template.getValue();
210        builder.includedDiscounts = template.getIncludedDiscounts();
211        return builder;
212    }
213
214}