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