001
002package com.commercetools.importapi.models.producttypes;
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 * AttributeDefinitionBuilder
014 * <hr>
015 * Example to create an instance using the builder pattern
016 * <div class=code-example>
017 * <pre><code class='java'>
018 *     AttributeDefinition attributeDefinition = AttributeDefinition.builder()
019 *             .type(typeBuilder -> typeBuilder)
020 *             .name("{name}")
021 *             .label(labelBuilder -> labelBuilder)
022 *             .isRequired(true)
023 *             .build()
024 * </code></pre>
025 * </div>
026 */
027@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen")
028public class AttributeDefinitionBuilder implements Builder<AttributeDefinition> {
029
030    private com.commercetools.importapi.models.producttypes.AttributeType type;
031
032    private String name;
033
034    private com.commercetools.importapi.models.common.LocalizedString label;
035
036    private Boolean isRequired;
037
038    @Nullable
039    private com.commercetools.importapi.models.producttypes.AttributeConstraintEnum attributeConstraint;
040
041    @Nullable
042    private com.commercetools.importapi.models.common.LocalizedString inputTip;
043
044    @Nullable
045    private com.commercetools.importapi.models.producttypes.TextInputHint inputHint;
046
047    @Nullable
048    private Boolean isSearchable;
049
050    /**
051     * set the value to the type
052     * @param type value to be set
053     * @return Builder
054     */
055
056    public AttributeDefinitionBuilder type(final com.commercetools.importapi.models.producttypes.AttributeType type) {
057        this.type = type;
058        return this;
059    }
060
061    /**
062     * set the value to the type using the builder function
063     * @param builder function to build the type value
064     * @return Builder
065     */
066
067    public AttributeDefinitionBuilder type(
068            Function<com.commercetools.importapi.models.producttypes.AttributeTypeBuilder, Builder<? extends com.commercetools.importapi.models.producttypes.AttributeType>> builder) {
069        this.type = builder.apply(com.commercetools.importapi.models.producttypes.AttributeTypeBuilder.of()).build();
070        return this;
071    }
072
073    /**
074     * set the value to the name
075     * @param name value to be set
076     * @return Builder
077     */
078
079    public AttributeDefinitionBuilder name(final String name) {
080        this.name = name;
081        return this;
082    }
083
084    /**
085     *  <p>A localized string is a JSON object where the keys are of IETF language tag, and the values the corresponding strings used for that language.</p>
086     *  <pre><code>{
087     *    "de": "Hundefutter",
088     *    "en": "dog food"
089     *  }
090     *  </code></pre>
091     * @param builder function to build the label value
092     * @return Builder
093     */
094
095    public AttributeDefinitionBuilder label(
096            Function<com.commercetools.importapi.models.common.LocalizedStringBuilder, com.commercetools.importapi.models.common.LocalizedStringBuilder> builder) {
097        this.label = builder.apply(com.commercetools.importapi.models.common.LocalizedStringBuilder.of()).build();
098        return this;
099    }
100
101    /**
102     *  <p>A localized string is a JSON object where the keys are of IETF language tag, and the values the corresponding strings used for that language.</p>
103     *  <pre><code>{
104     *    "de": "Hundefutter",
105     *    "en": "dog food"
106     *  }
107     *  </code></pre>
108     * @param builder function to build the label value
109     * @return Builder
110     */
111
112    public AttributeDefinitionBuilder withLabel(
113            Function<com.commercetools.importapi.models.common.LocalizedStringBuilder, com.commercetools.importapi.models.common.LocalizedString> builder) {
114        this.label = builder.apply(com.commercetools.importapi.models.common.LocalizedStringBuilder.of());
115        return this;
116    }
117
118    /**
119     *  <p>A localized string is a JSON object where the keys are of IETF language tag, and the values the corresponding strings used for that language.</p>
120     *  <pre><code>{
121     *    "de": "Hundefutter",
122     *    "en": "dog food"
123     *  }
124     *  </code></pre>
125     * @param label value to be set
126     * @return Builder
127     */
128
129    public AttributeDefinitionBuilder label(final com.commercetools.importapi.models.common.LocalizedString label) {
130        this.label = label;
131        return this;
132    }
133
134    /**
135     * set the value to the isRequired
136     * @param isRequired value to be set
137     * @return Builder
138     */
139
140    public AttributeDefinitionBuilder isRequired(final Boolean isRequired) {
141        this.isRequired = isRequired;
142        return this;
143    }
144
145    /**
146     * set the value to the attributeConstraint
147     * @param attributeConstraint value to be set
148     * @return Builder
149     */
150
151    public AttributeDefinitionBuilder attributeConstraint(
152            @Nullable final com.commercetools.importapi.models.producttypes.AttributeConstraintEnum attributeConstraint) {
153        this.attributeConstraint = attributeConstraint;
154        return this;
155    }
156
157    /**
158     *  <p>A localized string is a JSON object where the keys are of IETF language tag, and the values the corresponding strings used for that language.</p>
159     *  <pre><code>{
160     *    "de": "Hundefutter",
161     *    "en": "dog food"
162     *  }
163     *  </code></pre>
164     * @param builder function to build the inputTip value
165     * @return Builder
166     */
167
168    public AttributeDefinitionBuilder inputTip(
169            Function<com.commercetools.importapi.models.common.LocalizedStringBuilder, com.commercetools.importapi.models.common.LocalizedStringBuilder> builder) {
170        this.inputTip = builder.apply(com.commercetools.importapi.models.common.LocalizedStringBuilder.of()).build();
171        return this;
172    }
173
174    /**
175     *  <p>A localized string is a JSON object where the keys are of IETF language tag, and the values the corresponding strings used for that language.</p>
176     *  <pre><code>{
177     *    "de": "Hundefutter",
178     *    "en": "dog food"
179     *  }
180     *  </code></pre>
181     * @param builder function to build the inputTip value
182     * @return Builder
183     */
184
185    public AttributeDefinitionBuilder withInputTip(
186            Function<com.commercetools.importapi.models.common.LocalizedStringBuilder, com.commercetools.importapi.models.common.LocalizedString> builder) {
187        this.inputTip = builder.apply(com.commercetools.importapi.models.common.LocalizedStringBuilder.of());
188        return this;
189    }
190
191    /**
192     *  <p>A localized string is a JSON object where the keys are of IETF language tag, and the values the corresponding strings used for that language.</p>
193     *  <pre><code>{
194     *    "de": "Hundefutter",
195     *    "en": "dog food"
196     *  }
197     *  </code></pre>
198     * @param inputTip value to be set
199     * @return Builder
200     */
201
202    public AttributeDefinitionBuilder inputTip(
203            @Nullable final com.commercetools.importapi.models.common.LocalizedString inputTip) {
204        this.inputTip = inputTip;
205        return this;
206    }
207
208    /**
209     * set the value to the inputHint
210     * @param inputHint value to be set
211     * @return Builder
212     */
213
214    public AttributeDefinitionBuilder inputHint(
215            @Nullable final com.commercetools.importapi.models.producttypes.TextInputHint inputHint) {
216        this.inputHint = inputHint;
217        return this;
218    }
219
220    /**
221     * set the value to the isSearchable
222     * @param isSearchable value to be set
223     * @return Builder
224     */
225
226    public AttributeDefinitionBuilder isSearchable(@Nullable final Boolean isSearchable) {
227        this.isSearchable = isSearchable;
228        return this;
229    }
230
231    /**
232     * value of type}
233     * @return type
234     */
235
236    public com.commercetools.importapi.models.producttypes.AttributeType getType() {
237        return this.type;
238    }
239
240    /**
241     * value of name}
242     * @return name
243     */
244
245    public String getName() {
246        return this.name;
247    }
248
249    /**
250     *  <p>A localized string is a JSON object where the keys are of IETF language tag, and the values the corresponding strings used for that language.</p>
251     *  <pre><code>{
252     *    "de": "Hundefutter",
253     *    "en": "dog food"
254     *  }
255     *  </code></pre>
256     * @return label
257     */
258
259    public com.commercetools.importapi.models.common.LocalizedString getLabel() {
260        return this.label;
261    }
262
263    /**
264     * value of isRequired}
265     * @return isRequired
266     */
267
268    public Boolean getIsRequired() {
269        return this.isRequired;
270    }
271
272    /**
273     * value of attributeConstraint}
274     * @return attributeConstraint
275     */
276
277    @Nullable
278    public com.commercetools.importapi.models.producttypes.AttributeConstraintEnum getAttributeConstraint() {
279        return this.attributeConstraint;
280    }
281
282    /**
283     *  <p>A localized string is a JSON object where the keys are of IETF language tag, and the values the corresponding strings used for that language.</p>
284     *  <pre><code>{
285     *    "de": "Hundefutter",
286     *    "en": "dog food"
287     *  }
288     *  </code></pre>
289     * @return inputTip
290     */
291
292    @Nullable
293    public com.commercetools.importapi.models.common.LocalizedString getInputTip() {
294        return this.inputTip;
295    }
296
297    /**
298     * value of inputHint}
299     * @return inputHint
300     */
301
302    @Nullable
303    public com.commercetools.importapi.models.producttypes.TextInputHint getInputHint() {
304        return this.inputHint;
305    }
306
307    /**
308     * value of isSearchable}
309     * @return isSearchable
310     */
311
312    @Nullable
313    public Boolean getIsSearchable() {
314        return this.isSearchable;
315    }
316
317    /**
318     * builds AttributeDefinition with checking for non-null required values
319     * @return AttributeDefinition
320     */
321    public AttributeDefinition build() {
322        Objects.requireNonNull(type, AttributeDefinition.class + ": type is missing");
323        Objects.requireNonNull(name, AttributeDefinition.class + ": name is missing");
324        Objects.requireNonNull(label, AttributeDefinition.class + ": label is missing");
325        Objects.requireNonNull(isRequired, AttributeDefinition.class + ": isRequired is missing");
326        return new AttributeDefinitionImpl(type, name, label, isRequired, attributeConstraint, inputTip, inputHint,
327            isSearchable);
328    }
329
330    /**
331     * builds AttributeDefinition without checking for non-null required values
332     * @return AttributeDefinition
333     */
334    public AttributeDefinition buildUnchecked() {
335        return new AttributeDefinitionImpl(type, name, label, isRequired, attributeConstraint, inputTip, inputHint,
336            isSearchable);
337    }
338
339    /**
340     * factory method for an instance of AttributeDefinitionBuilder
341     * @return builder
342     */
343    public static AttributeDefinitionBuilder of() {
344        return new AttributeDefinitionBuilder();
345    }
346
347    /**
348     * create builder for AttributeDefinition instance
349     * @param template instance with prefilled values for the builder
350     * @return builder
351     */
352    public static AttributeDefinitionBuilder of(final AttributeDefinition template) {
353        AttributeDefinitionBuilder builder = new AttributeDefinitionBuilder();
354        builder.type = template.getType();
355        builder.name = template.getName();
356        builder.label = template.getLabel();
357        builder.isRequired = template.getIsRequired();
358        builder.attributeConstraint = template.getAttributeConstraint();
359        builder.inputTip = template.getInputTip();
360        builder.inputHint = template.getInputHint();
361        builder.isSearchable = template.getIsSearchable();
362        return builder;
363    }
364
365}