001
002package com.commercetools.api.models.attribute_group;
003
004import java.util.*;
005import java.util.function.Function;
006
007import javax.annotation.Nullable;
008
009import io.vrap.rmf.base.client.Builder;
010import io.vrap.rmf.base.client.utils.Generated;
011
012/**
013 * AttributeGroupDraftBuilder
014 * <hr>
015 * Example to create an instance using the builder pattern
016 * <div class=code-example>
017 * <pre><code class='java'>
018 *     AttributeGroupDraft attributeGroupDraft = AttributeGroupDraft.builder()
019 *             .name(nameBuilder -> nameBuilder)
020 *             .plusAttributes(attributesBuilder -> attributesBuilder)
021 *             .build()
022 * </code></pre>
023 * </div>
024 */
025@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen")
026public class AttributeGroupDraftBuilder implements Builder<AttributeGroupDraft> {
027
028    private com.commercetools.api.models.common.LocalizedString name;
029
030    @Nullable
031    private com.commercetools.api.models.common.LocalizedString description;
032
033    private java.util.List<com.commercetools.api.models.attribute_group.AttributeReference> attributes;
034
035    @Nullable
036    private String key;
037
038    /**
039     *  <p>Name of the AttributeGroup.</p>
040     * @param builder function to build the name value
041     * @return Builder
042     */
043
044    public AttributeGroupDraftBuilder name(
045            Function<com.commercetools.api.models.common.LocalizedStringBuilder, com.commercetools.api.models.common.LocalizedStringBuilder> builder) {
046        this.name = builder.apply(com.commercetools.api.models.common.LocalizedStringBuilder.of()).build();
047        return this;
048    }
049
050    /**
051     *  <p>Name of the AttributeGroup.</p>
052     * @param builder function to build the name value
053     * @return Builder
054     */
055
056    public AttributeGroupDraftBuilder withName(
057            Function<com.commercetools.api.models.common.LocalizedStringBuilder, com.commercetools.api.models.common.LocalizedString> builder) {
058        this.name = builder.apply(com.commercetools.api.models.common.LocalizedStringBuilder.of());
059        return this;
060    }
061
062    /**
063     *  <p>Name of the AttributeGroup.</p>
064     * @param name value to be set
065     * @return Builder
066     */
067
068    public AttributeGroupDraftBuilder name(final com.commercetools.api.models.common.LocalizedString name) {
069        this.name = name;
070        return this;
071    }
072
073    /**
074     *  <p>Description of the AttributeGroup.</p>
075     * @param builder function to build the description value
076     * @return Builder
077     */
078
079    public AttributeGroupDraftBuilder description(
080            Function<com.commercetools.api.models.common.LocalizedStringBuilder, com.commercetools.api.models.common.LocalizedStringBuilder> builder) {
081        this.description = builder.apply(com.commercetools.api.models.common.LocalizedStringBuilder.of()).build();
082        return this;
083    }
084
085    /**
086     *  <p>Description of the AttributeGroup.</p>
087     * @param builder function to build the description value
088     * @return Builder
089     */
090
091    public AttributeGroupDraftBuilder withDescription(
092            Function<com.commercetools.api.models.common.LocalizedStringBuilder, com.commercetools.api.models.common.LocalizedString> builder) {
093        this.description = builder.apply(com.commercetools.api.models.common.LocalizedStringBuilder.of());
094        return this;
095    }
096
097    /**
098     *  <p>Description of the AttributeGroup.</p>
099     * @param description value to be set
100     * @return Builder
101     */
102
103    public AttributeGroupDraftBuilder description(
104            @Nullable final com.commercetools.api.models.common.LocalizedString description) {
105        this.description = description;
106        return this;
107    }
108
109    /**
110     *  <p>Attributes with unique values.</p>
111     * @param attributes value to be set
112     * @return Builder
113     */
114
115    public AttributeGroupDraftBuilder attributes(
116            final com.commercetools.api.models.attribute_group.AttributeReference... attributes) {
117        this.attributes = new ArrayList<>(Arrays.asList(attributes));
118        return this;
119    }
120
121    /**
122     *  <p>Attributes with unique values.</p>
123     * @param attributes value to be set
124     * @return Builder
125     */
126
127    public AttributeGroupDraftBuilder attributes(
128            final java.util.List<com.commercetools.api.models.attribute_group.AttributeReference> attributes) {
129        this.attributes = attributes;
130        return this;
131    }
132
133    /**
134     *  <p>Attributes with unique values.</p>
135     * @param attributes value to be set
136     * @return Builder
137     */
138
139    public AttributeGroupDraftBuilder plusAttributes(
140            final com.commercetools.api.models.attribute_group.AttributeReference... attributes) {
141        if (this.attributes == null) {
142            this.attributes = new ArrayList<>();
143        }
144        this.attributes.addAll(Arrays.asList(attributes));
145        return this;
146    }
147
148    /**
149     *  <p>Attributes with unique values.</p>
150     * @param builder function to build the attributes value
151     * @return Builder
152     */
153
154    public AttributeGroupDraftBuilder plusAttributes(
155            Function<com.commercetools.api.models.attribute_group.AttributeReferenceBuilder, com.commercetools.api.models.attribute_group.AttributeReferenceBuilder> builder) {
156        if (this.attributes == null) {
157            this.attributes = new ArrayList<>();
158        }
159        this.attributes.add(
160            builder.apply(com.commercetools.api.models.attribute_group.AttributeReferenceBuilder.of()).build());
161        return this;
162    }
163
164    /**
165     *  <p>Attributes with unique values.</p>
166     * @param builder function to build the attributes value
167     * @return Builder
168     */
169
170    public AttributeGroupDraftBuilder withAttributes(
171            Function<com.commercetools.api.models.attribute_group.AttributeReferenceBuilder, com.commercetools.api.models.attribute_group.AttributeReferenceBuilder> builder) {
172        this.attributes = new ArrayList<>();
173        this.attributes.add(
174            builder.apply(com.commercetools.api.models.attribute_group.AttributeReferenceBuilder.of()).build());
175        return this;
176    }
177
178    /**
179     *  <p>Attributes with unique values.</p>
180     * @param builder function to build the attributes value
181     * @return Builder
182     */
183
184    public AttributeGroupDraftBuilder addAttributes(
185            Function<com.commercetools.api.models.attribute_group.AttributeReferenceBuilder, com.commercetools.api.models.attribute_group.AttributeReference> builder) {
186        return plusAttributes(
187            builder.apply(com.commercetools.api.models.attribute_group.AttributeReferenceBuilder.of()));
188    }
189
190    /**
191     *  <p>Attributes with unique values.</p>
192     * @param builder function to build the attributes value
193     * @return Builder
194     */
195
196    public AttributeGroupDraftBuilder setAttributes(
197            Function<com.commercetools.api.models.attribute_group.AttributeReferenceBuilder, com.commercetools.api.models.attribute_group.AttributeReference> builder) {
198        return attributes(builder.apply(com.commercetools.api.models.attribute_group.AttributeReferenceBuilder.of()));
199    }
200
201    /**
202     *  <p>User-defined unique identifier for the AttributeGroup.</p>
203     * @param key value to be set
204     * @return Builder
205     */
206
207    public AttributeGroupDraftBuilder key(@Nullable final String key) {
208        this.key = key;
209        return this;
210    }
211
212    /**
213     *  <p>Name of the AttributeGroup.</p>
214     * @return name
215     */
216
217    public com.commercetools.api.models.common.LocalizedString getName() {
218        return this.name;
219    }
220
221    /**
222     *  <p>Description of the AttributeGroup.</p>
223     * @return description
224     */
225
226    @Nullable
227    public com.commercetools.api.models.common.LocalizedString getDescription() {
228        return this.description;
229    }
230
231    /**
232     *  <p>Attributes with unique values.</p>
233     * @return attributes
234     */
235
236    public java.util.List<com.commercetools.api.models.attribute_group.AttributeReference> getAttributes() {
237        return this.attributes;
238    }
239
240    /**
241     *  <p>User-defined unique identifier for the AttributeGroup.</p>
242     * @return key
243     */
244
245    @Nullable
246    public String getKey() {
247        return this.key;
248    }
249
250    /**
251     * builds AttributeGroupDraft with checking for non-null required values
252     * @return AttributeGroupDraft
253     */
254    public AttributeGroupDraft build() {
255        Objects.requireNonNull(name, AttributeGroupDraft.class + ": name is missing");
256        Objects.requireNonNull(attributes, AttributeGroupDraft.class + ": attributes is missing");
257        return new AttributeGroupDraftImpl(name, description, attributes, key);
258    }
259
260    /**
261     * builds AttributeGroupDraft without checking for non-null required values
262     * @return AttributeGroupDraft
263     */
264    public AttributeGroupDraft buildUnchecked() {
265        return new AttributeGroupDraftImpl(name, description, attributes, key);
266    }
267
268    /**
269     * factory method for an instance of AttributeGroupDraftBuilder
270     * @return builder
271     */
272    public static AttributeGroupDraftBuilder of() {
273        return new AttributeGroupDraftBuilder();
274    }
275
276    /**
277     * create builder for AttributeGroupDraft instance
278     * @param template instance with prefilled values for the builder
279     * @return builder
280     */
281    public static AttributeGroupDraftBuilder of(final AttributeGroupDraft template) {
282        AttributeGroupDraftBuilder builder = new AttributeGroupDraftBuilder();
283        builder.name = template.getName();
284        builder.description = template.getDescription();
285        builder.attributes = template.getAttributes();
286        builder.key = template.getKey();
287        return builder;
288    }
289
290}