001
002package com.commercetools.api.models.me;
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 * MyBusinessUnitAssociateDraftBuilder
012 * <hr>
013 * Example to create an instance using the builder pattern
014 * <div class=code-example>
015 * <pre><code class='java'>
016 *     MyBusinessUnitAssociateDraft myBusinessUnitAssociateDraft = MyBusinessUnitAssociateDraft.builder()
017 *             .version(0.3)
018 *             .customer(customerBuilder -> customerBuilder)
019 *             .plusAssociateRoleAssignments(associateRoleAssignmentsBuilder -> associateRoleAssignmentsBuilder)
020 *             .build()
021 * </code></pre>
022 * </div>
023 */
024@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen")
025public class MyBusinessUnitAssociateDraftBuilder implements Builder<MyBusinessUnitAssociateDraft> {
026
027    private Long version;
028
029    private com.commercetools.api.models.me.MyCustomerDraft customer;
030
031    private java.util.List<com.commercetools.api.models.business_unit.AssociateRoleAssignmentDraft> associateRoleAssignments;
032
033    /**
034     *  <p>Expected version of the BusinessUnit on which the changes should be applied. If the expected version does not match the actual version, a 409 Conflict error will be returned.</p>
035     * @param version value to be set
036     * @return Builder
037     */
038
039    public MyBusinessUnitAssociateDraftBuilder version(final Long version) {
040        this.version = version;
041        return this;
042    }
043
044    /**
045     *  <p>Customer to create and assign to the Business Unit.</p>
046     * @param builder function to build the customer value
047     * @return Builder
048     */
049
050    public MyBusinessUnitAssociateDraftBuilder customer(
051            Function<com.commercetools.api.models.me.MyCustomerDraftBuilder, com.commercetools.api.models.me.MyCustomerDraftBuilder> builder) {
052        this.customer = builder.apply(com.commercetools.api.models.me.MyCustomerDraftBuilder.of()).build();
053        return this;
054    }
055
056    /**
057     *  <p>Customer to create and assign to the Business Unit.</p>
058     * @param builder function to build the customer value
059     * @return Builder
060     */
061
062    public MyBusinessUnitAssociateDraftBuilder withCustomer(
063            Function<com.commercetools.api.models.me.MyCustomerDraftBuilder, com.commercetools.api.models.me.MyCustomerDraft> builder) {
064        this.customer = builder.apply(com.commercetools.api.models.me.MyCustomerDraftBuilder.of());
065        return this;
066    }
067
068    /**
069     *  <p>Customer to create and assign to the Business Unit.</p>
070     * @param customer value to be set
071     * @return Builder
072     */
073
074    public MyBusinessUnitAssociateDraftBuilder customer(
075            final com.commercetools.api.models.me.MyCustomerDraft customer) {
076        this.customer = customer;
077        return this;
078    }
079
080    /**
081     *  <p>Roles assigned to the new Associate within a Business Unit.</p>
082     * @param associateRoleAssignments value to be set
083     * @return Builder
084     */
085
086    public MyBusinessUnitAssociateDraftBuilder associateRoleAssignments(
087            final com.commercetools.api.models.business_unit.AssociateRoleAssignmentDraft... associateRoleAssignments) {
088        this.associateRoleAssignments = new ArrayList<>(Arrays.asList(associateRoleAssignments));
089        return this;
090    }
091
092    /**
093     *  <p>Roles assigned to the new Associate within a Business Unit.</p>
094     * @param associateRoleAssignments value to be set
095     * @return Builder
096     */
097
098    public MyBusinessUnitAssociateDraftBuilder associateRoleAssignments(
099            final java.util.List<com.commercetools.api.models.business_unit.AssociateRoleAssignmentDraft> associateRoleAssignments) {
100        this.associateRoleAssignments = associateRoleAssignments;
101        return this;
102    }
103
104    /**
105     *  <p>Roles assigned to the new Associate within a Business Unit.</p>
106     * @param associateRoleAssignments value to be set
107     * @return Builder
108     */
109
110    public MyBusinessUnitAssociateDraftBuilder plusAssociateRoleAssignments(
111            final com.commercetools.api.models.business_unit.AssociateRoleAssignmentDraft... associateRoleAssignments) {
112        if (this.associateRoleAssignments == null) {
113            this.associateRoleAssignments = new ArrayList<>();
114        }
115        this.associateRoleAssignments.addAll(Arrays.asList(associateRoleAssignments));
116        return this;
117    }
118
119    /**
120     *  <p>Roles assigned to the new Associate within a Business Unit.</p>
121     * @param builder function to build the associateRoleAssignments value
122     * @return Builder
123     */
124
125    public MyBusinessUnitAssociateDraftBuilder plusAssociateRoleAssignments(
126            Function<com.commercetools.api.models.business_unit.AssociateRoleAssignmentDraftBuilder, com.commercetools.api.models.business_unit.AssociateRoleAssignmentDraftBuilder> builder) {
127        if (this.associateRoleAssignments == null) {
128            this.associateRoleAssignments = new ArrayList<>();
129        }
130        this.associateRoleAssignments.add(
131            builder.apply(com.commercetools.api.models.business_unit.AssociateRoleAssignmentDraftBuilder.of()).build());
132        return this;
133    }
134
135    /**
136     *  <p>Roles assigned to the new Associate within a Business Unit.</p>
137     * @param builder function to build the associateRoleAssignments value
138     * @return Builder
139     */
140
141    public MyBusinessUnitAssociateDraftBuilder withAssociateRoleAssignments(
142            Function<com.commercetools.api.models.business_unit.AssociateRoleAssignmentDraftBuilder, com.commercetools.api.models.business_unit.AssociateRoleAssignmentDraftBuilder> builder) {
143        this.associateRoleAssignments = new ArrayList<>();
144        this.associateRoleAssignments.add(
145            builder.apply(com.commercetools.api.models.business_unit.AssociateRoleAssignmentDraftBuilder.of()).build());
146        return this;
147    }
148
149    /**
150     *  <p>Roles assigned to the new Associate within a Business Unit.</p>
151     * @param builder function to build the associateRoleAssignments value
152     * @return Builder
153     */
154
155    public MyBusinessUnitAssociateDraftBuilder addAssociateRoleAssignments(
156            Function<com.commercetools.api.models.business_unit.AssociateRoleAssignmentDraftBuilder, com.commercetools.api.models.business_unit.AssociateRoleAssignmentDraft> builder) {
157        return plusAssociateRoleAssignments(
158            builder.apply(com.commercetools.api.models.business_unit.AssociateRoleAssignmentDraftBuilder.of()));
159    }
160
161    /**
162     *  <p>Roles assigned to the new Associate within a Business Unit.</p>
163     * @param builder function to build the associateRoleAssignments value
164     * @return Builder
165     */
166
167    public MyBusinessUnitAssociateDraftBuilder setAssociateRoleAssignments(
168            Function<com.commercetools.api.models.business_unit.AssociateRoleAssignmentDraftBuilder, com.commercetools.api.models.business_unit.AssociateRoleAssignmentDraft> builder) {
169        return associateRoleAssignments(
170            builder.apply(com.commercetools.api.models.business_unit.AssociateRoleAssignmentDraftBuilder.of()));
171    }
172
173    /**
174     *  <p>Expected version of the BusinessUnit on which the changes should be applied. If the expected version does not match the actual version, a 409 Conflict error will be returned.</p>
175     * @return version
176     */
177
178    public Long getVersion() {
179        return this.version;
180    }
181
182    /**
183     *  <p>Customer to create and assign to the Business Unit.</p>
184     * @return customer
185     */
186
187    public com.commercetools.api.models.me.MyCustomerDraft getCustomer() {
188        return this.customer;
189    }
190
191    /**
192     *  <p>Roles assigned to the new Associate within a Business Unit.</p>
193     * @return associateRoleAssignments
194     */
195
196    public java.util.List<com.commercetools.api.models.business_unit.AssociateRoleAssignmentDraft> getAssociateRoleAssignments() {
197        return this.associateRoleAssignments;
198    }
199
200    /**
201     * builds MyBusinessUnitAssociateDraft with checking for non-null required values
202     * @return MyBusinessUnitAssociateDraft
203     */
204    public MyBusinessUnitAssociateDraft build() {
205        Objects.requireNonNull(version, MyBusinessUnitAssociateDraft.class + ": version is missing");
206        Objects.requireNonNull(customer, MyBusinessUnitAssociateDraft.class + ": customer is missing");
207        Objects.requireNonNull(associateRoleAssignments,
208            MyBusinessUnitAssociateDraft.class + ": associateRoleAssignments is missing");
209        return new MyBusinessUnitAssociateDraftImpl(version, customer, associateRoleAssignments);
210    }
211
212    /**
213     * builds MyBusinessUnitAssociateDraft without checking for non-null required values
214     * @return MyBusinessUnitAssociateDraft
215     */
216    public MyBusinessUnitAssociateDraft buildUnchecked() {
217        return new MyBusinessUnitAssociateDraftImpl(version, customer, associateRoleAssignments);
218    }
219
220    /**
221     * factory method for an instance of MyBusinessUnitAssociateDraftBuilder
222     * @return builder
223     */
224    public static MyBusinessUnitAssociateDraftBuilder of() {
225        return new MyBusinessUnitAssociateDraftBuilder();
226    }
227
228    /**
229     * create builder for MyBusinessUnitAssociateDraft instance
230     * @param template instance with prefilled values for the builder
231     * @return builder
232     */
233    public static MyBusinessUnitAssociateDraftBuilder of(final MyBusinessUnitAssociateDraft template) {
234        MyBusinessUnitAssociateDraftBuilder builder = new MyBusinessUnitAssociateDraftBuilder();
235        builder.version = template.getVersion();
236        builder.customer = template.getCustomer();
237        builder.associateRoleAssignments = template.getAssociateRoleAssignments();
238        return builder;
239    }
240
241}