001
002package com.commercetools.history.models.change;
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 * ChangeTransactionStateChangeBuilder
012 * <hr>
013 * Example to create an instance using the builder pattern
014 * <div class=code-example>
015 * <pre><code class='java'>
016 *     ChangeTransactionStateChange changeTransactionStateChange = ChangeTransactionStateChange.builder()
017 *             .change("{change}")
018 *             .previousValue(TransactionState.INITIAL)
019 *             .nextValue(TransactionState.INITIAL)
020 *             .transaction(transactionBuilder -> transactionBuilder)
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 ChangeTransactionStateChangeBuilder implements Builder<ChangeTransactionStateChange> {
027
028    private String change;
029
030    private com.commercetools.history.models.common.TransactionState previousValue;
031
032    private com.commercetools.history.models.common.TransactionState nextValue;
033
034    private com.commercetools.history.models.change_value.TransactionChangeValue transaction;
035
036    /**
037     * set the value to the change
038     * @param change value to be set
039     * @return Builder
040     */
041
042    public ChangeTransactionStateChangeBuilder change(final String change) {
043        this.change = change;
044        return this;
045    }
046
047    /**
048     *  <p>Value before the change.</p>
049     * @param previousValue value to be set
050     * @return Builder
051     */
052
053    public ChangeTransactionStateChangeBuilder previousValue(
054            final com.commercetools.history.models.common.TransactionState previousValue) {
055        this.previousValue = previousValue;
056        return this;
057    }
058
059    /**
060     *  <p>Value after the change.</p>
061     * @param nextValue value to be set
062     * @return Builder
063     */
064
065    public ChangeTransactionStateChangeBuilder nextValue(
066            final com.commercetools.history.models.common.TransactionState nextValue) {
067        this.nextValue = nextValue;
068        return this;
069    }
070
071    /**
072     *  <p>Holds information about the updated Transaction.</p>
073     * @param builder function to build the transaction value
074     * @return Builder
075     */
076
077    public ChangeTransactionStateChangeBuilder transaction(
078            Function<com.commercetools.history.models.change_value.TransactionChangeValueBuilder, com.commercetools.history.models.change_value.TransactionChangeValueBuilder> builder) {
079        this.transaction = builder
080                .apply(com.commercetools.history.models.change_value.TransactionChangeValueBuilder.of())
081                .build();
082        return this;
083    }
084
085    /**
086     *  <p>Holds information about the updated Transaction.</p>
087     * @param builder function to build the transaction value
088     * @return Builder
089     */
090
091    public ChangeTransactionStateChangeBuilder withTransaction(
092            Function<com.commercetools.history.models.change_value.TransactionChangeValueBuilder, com.commercetools.history.models.change_value.TransactionChangeValue> builder) {
093        this.transaction = builder
094                .apply(com.commercetools.history.models.change_value.TransactionChangeValueBuilder.of());
095        return this;
096    }
097
098    /**
099     *  <p>Holds information about the updated Transaction.</p>
100     * @param transaction value to be set
101     * @return Builder
102     */
103
104    public ChangeTransactionStateChangeBuilder transaction(
105            final com.commercetools.history.models.change_value.TransactionChangeValue transaction) {
106        this.transaction = transaction;
107        return this;
108    }
109
110    /**
111     * value of change}
112     * @return change
113     */
114
115    public String getChange() {
116        return this.change;
117    }
118
119    /**
120     *  <p>Value before the change.</p>
121     * @return previousValue
122     */
123
124    public com.commercetools.history.models.common.TransactionState getPreviousValue() {
125        return this.previousValue;
126    }
127
128    /**
129     *  <p>Value after the change.</p>
130     * @return nextValue
131     */
132
133    public com.commercetools.history.models.common.TransactionState getNextValue() {
134        return this.nextValue;
135    }
136
137    /**
138     *  <p>Holds information about the updated Transaction.</p>
139     * @return transaction
140     */
141
142    public com.commercetools.history.models.change_value.TransactionChangeValue getTransaction() {
143        return this.transaction;
144    }
145
146    /**
147     * builds ChangeTransactionStateChange with checking for non-null required values
148     * @return ChangeTransactionStateChange
149     */
150    public ChangeTransactionStateChange build() {
151        Objects.requireNonNull(change, ChangeTransactionStateChange.class + ": change is missing");
152        Objects.requireNonNull(previousValue, ChangeTransactionStateChange.class + ": previousValue is missing");
153        Objects.requireNonNull(nextValue, ChangeTransactionStateChange.class + ": nextValue is missing");
154        Objects.requireNonNull(transaction, ChangeTransactionStateChange.class + ": transaction is missing");
155        return new ChangeTransactionStateChangeImpl(change, previousValue, nextValue, transaction);
156    }
157
158    /**
159     * builds ChangeTransactionStateChange without checking for non-null required values
160     * @return ChangeTransactionStateChange
161     */
162    public ChangeTransactionStateChange buildUnchecked() {
163        return new ChangeTransactionStateChangeImpl(change, previousValue, nextValue, transaction);
164    }
165
166    /**
167     * factory method for an instance of ChangeTransactionStateChangeBuilder
168     * @return builder
169     */
170    public static ChangeTransactionStateChangeBuilder of() {
171        return new ChangeTransactionStateChangeBuilder();
172    }
173
174    /**
175     * create builder for ChangeTransactionStateChange instance
176     * @param template instance with prefilled values for the builder
177     * @return builder
178     */
179    public static ChangeTransactionStateChangeBuilder of(final ChangeTransactionStateChange template) {
180        ChangeTransactionStateChangeBuilder builder = new ChangeTransactionStateChangeBuilder();
181        builder.change = template.getChange();
182        builder.previousValue = template.getPreviousValue();
183        builder.nextValue = template.getNextValue();
184        builder.transaction = template.getTransaction();
185        return builder;
186    }
187
188}