001
002package com.commercetools.api.models.standalone_price;
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 * StandalonePriceSetPriceTiersActionBuilder
012 * <hr>
013 * Example to create an instance using the builder pattern
014 * <div class=code-example>
015 * <pre><code class='java'>
016 *     StandalonePriceSetPriceTiersAction standalonePriceSetPriceTiersAction = StandalonePriceSetPriceTiersAction.builder()
017 *             .plusTiers(tiersBuilder -> tiersBuilder)
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 StandalonePriceSetPriceTiersActionBuilder implements Builder<StandalonePriceSetPriceTiersAction> {
024
025    private java.util.List<com.commercetools.api.models.common.PriceTierDraft> tiers;
026
027    /**
028     *  <p>Value to set. If empty, any existing value will be removed. The <code>minimumQuantity</code> of the PriceTiers must be unique and greater than <code>1</code>, otherwise an InvalidField error is returned.</p>
029     * @param tiers value to be set
030     * @return Builder
031     */
032
033    public StandalonePriceSetPriceTiersActionBuilder tiers(
034            final com.commercetools.api.models.common.PriceTierDraft... tiers) {
035        this.tiers = new ArrayList<>(Arrays.asList(tiers));
036        return this;
037    }
038
039    /**
040     *  <p>Value to set. If empty, any existing value will be removed. The <code>minimumQuantity</code> of the PriceTiers must be unique and greater than <code>1</code>, otherwise an InvalidField error is returned.</p>
041     * @param tiers value to be set
042     * @return Builder
043     */
044
045    public StandalonePriceSetPriceTiersActionBuilder tiers(
046            final java.util.List<com.commercetools.api.models.common.PriceTierDraft> tiers) {
047        this.tiers = tiers;
048        return this;
049    }
050
051    /**
052     *  <p>Value to set. If empty, any existing value will be removed. The <code>minimumQuantity</code> of the PriceTiers must be unique and greater than <code>1</code>, otherwise an InvalidField error is returned.</p>
053     * @param tiers value to be set
054     * @return Builder
055     */
056
057    public StandalonePriceSetPriceTiersActionBuilder plusTiers(
058            final com.commercetools.api.models.common.PriceTierDraft... tiers) {
059        if (this.tiers == null) {
060            this.tiers = new ArrayList<>();
061        }
062        this.tiers.addAll(Arrays.asList(tiers));
063        return this;
064    }
065
066    /**
067     *  <p>Value to set. If empty, any existing value will be removed. The <code>minimumQuantity</code> of the PriceTiers must be unique and greater than <code>1</code>, otherwise an InvalidField error is returned.</p>
068     * @param builder function to build the tiers value
069     * @return Builder
070     */
071
072    public StandalonePriceSetPriceTiersActionBuilder plusTiers(
073            Function<com.commercetools.api.models.common.PriceTierDraftBuilder, com.commercetools.api.models.common.PriceTierDraftBuilder> builder) {
074        if (this.tiers == null) {
075            this.tiers = new ArrayList<>();
076        }
077        this.tiers.add(builder.apply(com.commercetools.api.models.common.PriceTierDraftBuilder.of()).build());
078        return this;
079    }
080
081    /**
082     *  <p>Value to set. If empty, any existing value will be removed. The <code>minimumQuantity</code> of the PriceTiers must be unique and greater than <code>1</code>, otherwise an InvalidField error is returned.</p>
083     * @param builder function to build the tiers value
084     * @return Builder
085     */
086
087    public StandalonePriceSetPriceTiersActionBuilder withTiers(
088            Function<com.commercetools.api.models.common.PriceTierDraftBuilder, com.commercetools.api.models.common.PriceTierDraftBuilder> builder) {
089        this.tiers = new ArrayList<>();
090        this.tiers.add(builder.apply(com.commercetools.api.models.common.PriceTierDraftBuilder.of()).build());
091        return this;
092    }
093
094    /**
095     *  <p>Value to set. If empty, any existing value will be removed. The <code>minimumQuantity</code> of the PriceTiers must be unique and greater than <code>1</code>, otherwise an InvalidField error is returned.</p>
096     * @param builder function to build the tiers value
097     * @return Builder
098     */
099
100    public StandalonePriceSetPriceTiersActionBuilder addTiers(
101            Function<com.commercetools.api.models.common.PriceTierDraftBuilder, com.commercetools.api.models.common.PriceTierDraft> builder) {
102        return plusTiers(builder.apply(com.commercetools.api.models.common.PriceTierDraftBuilder.of()));
103    }
104
105    /**
106     *  <p>Value to set. If empty, any existing value will be removed. The <code>minimumQuantity</code> of the PriceTiers must be unique and greater than <code>1</code>, otherwise an InvalidField error is returned.</p>
107     * @param builder function to build the tiers value
108     * @return Builder
109     */
110
111    public StandalonePriceSetPriceTiersActionBuilder setTiers(
112            Function<com.commercetools.api.models.common.PriceTierDraftBuilder, com.commercetools.api.models.common.PriceTierDraft> builder) {
113        return tiers(builder.apply(com.commercetools.api.models.common.PriceTierDraftBuilder.of()));
114    }
115
116    /**
117     *  <p>Value to set. If empty, any existing value will be removed. The <code>minimumQuantity</code> of the PriceTiers must be unique and greater than <code>1</code>, otherwise an InvalidField error is returned.</p>
118     * @return tiers
119     */
120
121    public java.util.List<com.commercetools.api.models.common.PriceTierDraft> getTiers() {
122        return this.tiers;
123    }
124
125    /**
126     * builds StandalonePriceSetPriceTiersAction with checking for non-null required values
127     * @return StandalonePriceSetPriceTiersAction
128     */
129    public StandalonePriceSetPriceTiersAction build() {
130        Objects.requireNonNull(tiers, StandalonePriceSetPriceTiersAction.class + ": tiers is missing");
131        return new StandalonePriceSetPriceTiersActionImpl(tiers);
132    }
133
134    /**
135     * builds StandalonePriceSetPriceTiersAction without checking for non-null required values
136     * @return StandalonePriceSetPriceTiersAction
137     */
138    public StandalonePriceSetPriceTiersAction buildUnchecked() {
139        return new StandalonePriceSetPriceTiersActionImpl(tiers);
140    }
141
142    /**
143     * factory method for an instance of StandalonePriceSetPriceTiersActionBuilder
144     * @return builder
145     */
146    public static StandalonePriceSetPriceTiersActionBuilder of() {
147        return new StandalonePriceSetPriceTiersActionBuilder();
148    }
149
150    /**
151     * create builder for StandalonePriceSetPriceTiersAction instance
152     * @param template instance with prefilled values for the builder
153     * @return builder
154     */
155    public static StandalonePriceSetPriceTiersActionBuilder of(final StandalonePriceSetPriceTiersAction template) {
156        StandalonePriceSetPriceTiersActionBuilder builder = new StandalonePriceSetPriceTiersActionBuilder();
157        builder.tiers = template.getTiers();
158        return builder;
159    }
160
161}