001
002package com.commercetools.history.models.change;
003
004import java.time.*;
005import java.util.*;
006import java.util.function.Function;
007import java.util.stream.Collectors;
008
009import javax.annotation.Nullable;
010import javax.validation.Valid;
011import javax.validation.constraints.NotNull;
012
013import com.commercetools.history.models.change_value.AssetChangeValue;
014import com.commercetools.history.models.common.AssetSource;
015import com.fasterxml.jackson.annotation.*;
016import com.fasterxml.jackson.databind.annotation.*;
017
018import io.vrap.rmf.base.client.utils.Generated;
019
020/**
021 *  <p>Change triggered by the following update actions:</p>
022 *  <ul>
023 *   <li>Set Asset Sources on Categories.</li>
024 *   <li>Set Asset Sources on Products.</li>
025 *  </ul>
026 *
027 * <hr>
028 * Example to create an instance using the builder pattern
029 * <div class=code-example>
030 * <pre><code class='java'>
031 *     SetAssetSourcesChange setAssetSourcesChange = SetAssetSourcesChange.builder()
032 *             .change("{change}")
033 *             .plusPreviousValue(previousValueBuilder -> previousValueBuilder)
034 *             .plusNextValue(nextValueBuilder -> nextValueBuilder)
035 *             .asset(assetBuilder -> assetBuilder)
036 *             .build()
037 * </code></pre>
038 * </div>
039 */
040@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen")
041@JsonDeserialize(as = SetAssetSourcesChangeImpl.class)
042public interface SetAssetSourcesChange extends Change {
043
044    /**
045     * discriminator value for SetAssetSourcesChange
046     */
047    String SET_ASSET_SOURCES_CHANGE = "SetAssetSourcesChange";
048
049    /**
050     *
051     * @return change
052     */
053    @NotNull
054    @JsonProperty("change")
055    public String getChange();
056
057    /**
058     *
059     * @return type
060     */
061    @NotNull
062    @JsonProperty("type")
063    public String getType();
064
065    /**
066     *  <p>Value before the change.</p>
067     * @return previousValue
068     */
069    @NotNull
070    @Valid
071    @JsonProperty("previousValue")
072    public List<AssetSource> getPreviousValue();
073
074    /**
075     *  <p>Value after the change.</p>
076     * @return nextValue
077     */
078    @NotNull
079    @Valid
080    @JsonProperty("nextValue")
081    public List<AssetSource> getNextValue();
082
083    /**
084     *  <p>Information about the updated Asset.</p>
085     * @return asset
086     */
087    @NotNull
088    @Valid
089    @JsonProperty("asset")
090    public AssetChangeValue getAsset();
091
092    /**
093     * set change
094     * @param change value to be set
095     */
096
097    public void setChange(final String change);
098
099    /**
100     *  <p>Value before the change.</p>
101     * @param previousValue values to be set
102     */
103
104    @JsonIgnore
105    public void setPreviousValue(final AssetSource... previousValue);
106
107    /**
108     *  <p>Value before the change.</p>
109     * @param previousValue values to be set
110     */
111
112    public void setPreviousValue(final List<AssetSource> previousValue);
113
114    /**
115     *  <p>Value after the change.</p>
116     * @param nextValue values to be set
117     */
118
119    @JsonIgnore
120    public void setNextValue(final AssetSource... nextValue);
121
122    /**
123     *  <p>Value after the change.</p>
124     * @param nextValue values to be set
125     */
126
127    public void setNextValue(final List<AssetSource> nextValue);
128
129    /**
130     *  <p>Information about the updated Asset.</p>
131     * @param asset value to be set
132     */
133
134    public void setAsset(final AssetChangeValue asset);
135
136    /**
137     * factory method
138     * @return instance of SetAssetSourcesChange
139     */
140    public static SetAssetSourcesChange of() {
141        return new SetAssetSourcesChangeImpl();
142    }
143
144    /**
145     * factory method to create a shallow copy SetAssetSourcesChange
146     * @param template instance to be copied
147     * @return copy instance
148     */
149    public static SetAssetSourcesChange of(final SetAssetSourcesChange template) {
150        SetAssetSourcesChangeImpl instance = new SetAssetSourcesChangeImpl();
151        instance.setChange(template.getChange());
152        instance.setPreviousValue(template.getPreviousValue());
153        instance.setNextValue(template.getNextValue());
154        instance.setAsset(template.getAsset());
155        return instance;
156    }
157
158    /**
159     * factory method to create a deep copy of SetAssetSourcesChange
160     * @param template instance to be copied
161     * @return copy instance
162     */
163    @Nullable
164    public static SetAssetSourcesChange deepCopy(@Nullable final SetAssetSourcesChange template) {
165        if (template == null) {
166            return null;
167        }
168        SetAssetSourcesChangeImpl instance = new SetAssetSourcesChangeImpl();
169        instance.setChange(template.getChange());
170        instance.setPreviousValue(Optional.ofNullable(template.getPreviousValue())
171                .map(t -> t.stream()
172                        .map(com.commercetools.history.models.common.AssetSource::deepCopy)
173                        .collect(Collectors.toList()))
174                .orElse(null));
175        instance.setNextValue(Optional.ofNullable(template.getNextValue())
176                .map(t -> t.stream()
177                        .map(com.commercetools.history.models.common.AssetSource::deepCopy)
178                        .collect(Collectors.toList()))
179                .orElse(null));
180        instance.setAsset(com.commercetools.history.models.change_value.AssetChangeValue.deepCopy(template.getAsset()));
181        return instance;
182    }
183
184    /**
185     * builder factory method for SetAssetSourcesChange
186     * @return builder
187     */
188    public static SetAssetSourcesChangeBuilder builder() {
189        return SetAssetSourcesChangeBuilder.of();
190    }
191
192    /**
193     * create builder for SetAssetSourcesChange instance
194     * @param template instance with prefilled values for the builder
195     * @return builder
196     */
197    public static SetAssetSourcesChangeBuilder builder(final SetAssetSourcesChange template) {
198        return SetAssetSourcesChangeBuilder.of(template);
199    }
200
201    /**
202     * accessor map function
203     * @param <T> mapped type
204     * @param helper function to map the object
205     * @return mapped value
206     */
207    default <T> T withSetAssetSourcesChange(Function<SetAssetSourcesChange, T> helper) {
208        return helper.apply(this);
209    }
210
211    /**
212     * gives a TypeReference for usage with Jackson DataBind
213     * @return TypeReference
214     */
215    public static com.fasterxml.jackson.core.type.TypeReference<SetAssetSourcesChange> typeReference() {
216        return new com.fasterxml.jackson.core.type.TypeReference<SetAssetSourcesChange>() {
217            @Override
218            public String toString() {
219                return "TypeReference<SetAssetSourcesChange>";
220            }
221        };
222    }
223}