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