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 * AssetBuilder
012 * <hr>
013 * Example to create an instance using the builder pattern
014 * <div class=code-example>
015 * <pre><code class='java'>
016 *     Asset asset = Asset.builder()
017 *             .id("{id}")
018 *             .name(nameBuilder -> nameBuilder)
019 *             .description(descriptionBuilder -> descriptionBuilder)
020 *             .custom(customBuilder -> customBuilder)
021 *             .key("{key}")
022 *             .build()
023 * </code></pre>
024 * </div>
025 */
026@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen")
027public class AssetBuilder implements Builder<Asset> {
028
029    private String id;
030
031    private com.commercetools.history.models.common.LocalizedString name;
032
033    private com.commercetools.history.models.common.LocalizedString description;
034
035    private com.commercetools.history.models.common.CustomFields custom;
036
037    private String key;
038
039    /**
040     * set the value to the id
041     * @param id value to be set
042     * @return Builder
043     */
044
045    public AssetBuilder id(final String id) {
046        this.id = id;
047        return this;
048    }
049
050    /**
051     * set the value to the name using the builder function
052     * @param builder function to build the name value
053     * @return Builder
054     */
055
056    public AssetBuilder name(
057            Function<com.commercetools.history.models.common.LocalizedStringBuilder, com.commercetools.history.models.common.LocalizedStringBuilder> builder) {
058        this.name = builder.apply(com.commercetools.history.models.common.LocalizedStringBuilder.of()).build();
059        return this;
060    }
061
062    /**
063     * set the value to the name using the builder function
064     * @param builder function to build the name value
065     * @return Builder
066     */
067
068    public AssetBuilder withName(
069            Function<com.commercetools.history.models.common.LocalizedStringBuilder, com.commercetools.history.models.common.LocalizedString> builder) {
070        this.name = builder.apply(com.commercetools.history.models.common.LocalizedStringBuilder.of());
071        return this;
072    }
073
074    /**
075     * set the value to the name
076     * @param name value to be set
077     * @return Builder
078     */
079
080    public AssetBuilder name(final com.commercetools.history.models.common.LocalizedString name) {
081        this.name = name;
082        return this;
083    }
084
085    /**
086     * set the value to the description using the builder function
087     * @param builder function to build the description value
088     * @return Builder
089     */
090
091    public AssetBuilder description(
092            Function<com.commercetools.history.models.common.LocalizedStringBuilder, com.commercetools.history.models.common.LocalizedStringBuilder> builder) {
093        this.description = builder.apply(com.commercetools.history.models.common.LocalizedStringBuilder.of()).build();
094        return this;
095    }
096
097    /**
098     * set the value to the description using the builder function
099     * @param builder function to build the description value
100     * @return Builder
101     */
102
103    public AssetBuilder withDescription(
104            Function<com.commercetools.history.models.common.LocalizedStringBuilder, com.commercetools.history.models.common.LocalizedString> builder) {
105        this.description = builder.apply(com.commercetools.history.models.common.LocalizedStringBuilder.of());
106        return this;
107    }
108
109    /**
110     * set the value to the description
111     * @param description value to be set
112     * @return Builder
113     */
114
115    public AssetBuilder description(final com.commercetools.history.models.common.LocalizedString description) {
116        this.description = description;
117        return this;
118    }
119
120    /**
121     * set the value to the custom using the builder function
122     * @param builder function to build the custom value
123     * @return Builder
124     */
125
126    public AssetBuilder custom(
127            Function<com.commercetools.history.models.common.CustomFieldsBuilder, com.commercetools.history.models.common.CustomFieldsBuilder> builder) {
128        this.custom = builder.apply(com.commercetools.history.models.common.CustomFieldsBuilder.of()).build();
129        return this;
130    }
131
132    /**
133     * set the value to the custom using the builder function
134     * @param builder function to build the custom value
135     * @return Builder
136     */
137
138    public AssetBuilder withCustom(
139            Function<com.commercetools.history.models.common.CustomFieldsBuilder, com.commercetools.history.models.common.CustomFields> builder) {
140        this.custom = builder.apply(com.commercetools.history.models.common.CustomFieldsBuilder.of());
141        return this;
142    }
143
144    /**
145     * set the value to the custom
146     * @param custom value to be set
147     * @return Builder
148     */
149
150    public AssetBuilder custom(final com.commercetools.history.models.common.CustomFields custom) {
151        this.custom = custom;
152        return this;
153    }
154
155    /**
156     * set the value to the key
157     * @param key value to be set
158     * @return Builder
159     */
160
161    public AssetBuilder key(final String key) {
162        this.key = key;
163        return this;
164    }
165
166    /**
167     * value of id}
168     * @return id
169     */
170
171    public String getId() {
172        return this.id;
173    }
174
175    /**
176     * value of name}
177     * @return name
178     */
179
180    public com.commercetools.history.models.common.LocalizedString getName() {
181        return this.name;
182    }
183
184    /**
185     * value of description}
186     * @return description
187     */
188
189    public com.commercetools.history.models.common.LocalizedString getDescription() {
190        return this.description;
191    }
192
193    /**
194     * value of custom}
195     * @return custom
196     */
197
198    public com.commercetools.history.models.common.CustomFields getCustom() {
199        return this.custom;
200    }
201
202    /**
203     * value of key}
204     * @return key
205     */
206
207    public String getKey() {
208        return this.key;
209    }
210
211    /**
212     * builds Asset with checking for non-null required values
213     * @return Asset
214     */
215    public Asset build() {
216        Objects.requireNonNull(id, Asset.class + ": id is missing");
217        Objects.requireNonNull(name, Asset.class + ": name is missing");
218        Objects.requireNonNull(description, Asset.class + ": description is missing");
219        Objects.requireNonNull(custom, Asset.class + ": custom is missing");
220        Objects.requireNonNull(key, Asset.class + ": key is missing");
221        return new AssetImpl(id, name, description, custom, key);
222    }
223
224    /**
225     * builds Asset without checking for non-null required values
226     * @return Asset
227     */
228    public Asset buildUnchecked() {
229        return new AssetImpl(id, name, description, custom, key);
230    }
231
232    /**
233     * factory method for an instance of AssetBuilder
234     * @return builder
235     */
236    public static AssetBuilder of() {
237        return new AssetBuilder();
238    }
239
240    /**
241     * create builder for Asset instance
242     * @param template instance with prefilled values for the builder
243     * @return builder
244     */
245    public static AssetBuilder of(final Asset template) {
246        AssetBuilder builder = new AssetBuilder();
247        builder.id = template.getId();
248        builder.name = template.getName();
249        builder.description = template.getDescription();
250        builder.custom = template.getCustom();
251        builder.key = template.getKey();
252        return builder;
253    }
254
255}