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