001
002package com.commercetools.api.models.product;
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.fasterxml.jackson.annotation.*;
014import com.fasterxml.jackson.databind.annotation.*;
015
016import io.vrap.rmf.base.client.utils.Generated;
017
018/**
019 * ProductUpdate
020 *
021 * <hr>
022 * Example to create an instance using the builder pattern
023 * <div class=code-example>
024 * <pre><code class='java'>
025 *     ProductUpdate productUpdate = ProductUpdate.builder()
026 *             .version(0.3)
027 *             .plusActions(actionsBuilder -> actionsBuilder)
028 *             .build()
029 * </code></pre>
030 * </div>
031 */
032@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen")
033@JsonDeserialize(as = ProductUpdateImpl.class)
034public interface ProductUpdate
035        extends com.commercetools.api.models.ResourceUpdate<ProductUpdate, ProductUpdateAction, ProductUpdateBuilder> {
036
037    /**
038     *  <p>Expected version of the Product on which the changes should be applied. If the expected version does not match the actual version, a 409 Conflict will be returned.</p>
039     * @return version
040     */
041    @NotNull
042    @JsonProperty("version")
043    public Long getVersion();
044
045    /**
046     *  <p>Update actions to be performed on the Product.</p>
047     * @return actions
048     */
049    @NotNull
050    @Valid
051    @JsonProperty("actions")
052    public List<ProductUpdateAction> getActions();
053
054    /**
055     *  <p>Expected version of the Product on which the changes should be applied. If the expected version does not match the actual version, a 409 Conflict will be returned.</p>
056     * @param version value to be set
057     */
058
059    public void setVersion(final Long version);
060
061    /**
062     *  <p>Update actions to be performed on the Product.</p>
063     * @param actions values to be set
064     */
065
066    @JsonIgnore
067    public void setActions(final ProductUpdateAction... actions);
068
069    /**
070     *  <p>Update actions to be performed on the Product.</p>
071     * @param actions values to be set
072     */
073
074    public void setActions(final List<ProductUpdateAction> actions);
075
076    /**
077     * factory method
078     * @return instance of ProductUpdate
079     */
080    public static ProductUpdate of() {
081        return new ProductUpdateImpl();
082    }
083
084    /**
085     * factory method to create a shallow copy ProductUpdate
086     * @param template instance to be copied
087     * @return copy instance
088     */
089    public static ProductUpdate of(final ProductUpdate template) {
090        ProductUpdateImpl instance = new ProductUpdateImpl();
091        instance.setVersion(template.getVersion());
092        instance.setActions(template.getActions());
093        return instance;
094    }
095
096    /**
097     * factory method to create a deep copy of ProductUpdate
098     * @param template instance to be copied
099     * @return copy instance
100     */
101    @Nullable
102    public static ProductUpdate deepCopy(@Nullable final ProductUpdate template) {
103        if (template == null) {
104            return null;
105        }
106        ProductUpdateImpl instance = new ProductUpdateImpl();
107        instance.setVersion(template.getVersion());
108        instance.setActions(Optional.ofNullable(template.getActions())
109                .map(t -> t.stream()
110                        .map(com.commercetools.api.models.product.ProductUpdateAction::deepCopy)
111                        .collect(Collectors.toList()))
112                .orElse(null));
113        return instance;
114    }
115
116    /**
117     * builder factory method for ProductUpdate
118     * @return builder
119     */
120    public static ProductUpdateBuilder builder() {
121        return ProductUpdateBuilder.of();
122    }
123
124    /**
125     * create builder for ProductUpdate instance
126     * @param template instance with prefilled values for the builder
127     * @return builder
128     */
129    public static ProductUpdateBuilder builder(final ProductUpdate template) {
130        return ProductUpdateBuilder.of(template);
131    }
132
133    /**
134     * accessor map function
135     * @param <T> mapped type
136     * @param helper function to map the object
137     * @return mapped value
138     */
139    default <T> T withProductUpdate(Function<ProductUpdate, T> helper) {
140        return helper.apply(this);
141    }
142
143    /**
144     * gives a TypeReference for usage with Jackson DataBind
145     * @return TypeReference
146     */
147    public static com.fasterxml.jackson.core.type.TypeReference<ProductUpdate> typeReference() {
148        return new com.fasterxml.jackson.core.type.TypeReference<ProductUpdate>() {
149            @Override
150            public String toString() {
151                return "TypeReference<ProductUpdate>";
152            }
153        };
154    }
155}