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