001
002package com.commercetools.api.models.category;
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 * CategoryUpdateBuilder
012 * <hr>
013 * Example to create an instance using the builder pattern
014 * <div class=code-example>
015 * <pre><code class='java'>
016 *     CategoryUpdate categoryUpdate = CategoryUpdate.builder()
017 *             .version(0.3)
018 *             .plusActions(actionsBuilder -> actionsBuilder)
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 CategoryUpdateBuilder implements Builder<CategoryUpdate> {
025
026    private Long version;
027
028    private java.util.List<com.commercetools.api.models.category.CategoryUpdateAction> actions;
029
030    /**
031     *  <p>Expected version of the Category on which the changes should be applied. If the expected version does not match the actual version, a ConcurrentModification error is returned.</p>
032     * @param version value to be set
033     * @return Builder
034     */
035
036    public CategoryUpdateBuilder version(final Long version) {
037        this.version = version;
038        return this;
039    }
040
041    /**
042     *  <p>Update actions to be performed on the Category.</p>
043     * @param actions value to be set
044     * @return Builder
045     */
046
047    public CategoryUpdateBuilder actions(final com.commercetools.api.models.category.CategoryUpdateAction... actions) {
048        this.actions = new ArrayList<>(Arrays.asList(actions));
049        return this;
050    }
051
052    /**
053     *  <p>Update actions to be performed on the Category.</p>
054     * @param actions value to be set
055     * @return Builder
056     */
057
058    public CategoryUpdateBuilder actions(
059            final java.util.List<com.commercetools.api.models.category.CategoryUpdateAction> actions) {
060        this.actions = actions;
061        return this;
062    }
063
064    /**
065     *  <p>Update actions to be performed on the Category.</p>
066     * @param actions value to be set
067     * @return Builder
068     */
069
070    public CategoryUpdateBuilder plusActions(
071            final com.commercetools.api.models.category.CategoryUpdateAction... actions) {
072        if (this.actions == null) {
073            this.actions = new ArrayList<>();
074        }
075        this.actions.addAll(Arrays.asList(actions));
076        return this;
077    }
078
079    /**
080     *  <p>Update actions to be performed on the Category.</p>
081     * @param builder function to build the actions value
082     * @return Builder
083     */
084
085    public CategoryUpdateBuilder plusActions(
086            Function<com.commercetools.api.models.category.CategoryUpdateActionBuilder, Builder<? extends com.commercetools.api.models.category.CategoryUpdateAction>> builder) {
087        if (this.actions == null) {
088            this.actions = new ArrayList<>();
089        }
090        this.actions.add(builder.apply(com.commercetools.api.models.category.CategoryUpdateActionBuilder.of()).build());
091        return this;
092    }
093
094    /**
095     *  <p>Update actions to be performed on the Category.</p>
096     * @param builder function to build the actions value
097     * @return Builder
098     */
099
100    public CategoryUpdateBuilder withActions(
101            Function<com.commercetools.api.models.category.CategoryUpdateActionBuilder, Builder<? extends com.commercetools.api.models.category.CategoryUpdateAction>> builder) {
102        this.actions = new ArrayList<>();
103        this.actions.add(builder.apply(com.commercetools.api.models.category.CategoryUpdateActionBuilder.of()).build());
104        return this;
105    }
106
107    /**
108     *  <p>Expected version of the Category on which the changes should be applied. If the expected version does not match the actual version, a ConcurrentModification error is returned.</p>
109     * @return version
110     */
111
112    public Long getVersion() {
113        return this.version;
114    }
115
116    /**
117     *  <p>Update actions to be performed on the Category.</p>
118     * @return actions
119     */
120
121    public java.util.List<com.commercetools.api.models.category.CategoryUpdateAction> getActions() {
122        return this.actions;
123    }
124
125    /**
126     * builds CategoryUpdate with checking for non-null required values
127     * @return CategoryUpdate
128     */
129    public CategoryUpdate build() {
130        Objects.requireNonNull(version, CategoryUpdate.class + ": version is missing");
131        Objects.requireNonNull(actions, CategoryUpdate.class + ": actions is missing");
132        return new CategoryUpdateImpl(version, actions);
133    }
134
135    /**
136     * builds CategoryUpdate without checking for non-null required values
137     * @return CategoryUpdate
138     */
139    public CategoryUpdate buildUnchecked() {
140        return new CategoryUpdateImpl(version, actions);
141    }
142
143    /**
144     * factory method for an instance of CategoryUpdateBuilder
145     * @return builder
146     */
147    public static CategoryUpdateBuilder of() {
148        return new CategoryUpdateBuilder();
149    }
150
151    /**
152     * create builder for CategoryUpdate instance
153     * @param template instance with prefilled values for the builder
154     * @return builder
155     */
156    public static CategoryUpdateBuilder of(final CategoryUpdate template) {
157        CategoryUpdateBuilder builder = new CategoryUpdateBuilder();
158        builder.version = template.getVersion();
159        builder.actions = template.getActions();
160        return builder;
161    }
162
163}