001
002package com.commercetools.api.models.common;
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 * Update
020 *
021 * <hr>
022 * Example to create an instance using the builder pattern
023 * <div class=code-example>
024 * <pre><code class='java'>
025 *     Update update = Update.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 = UpdateImpl.class)
034public interface Update extends com.commercetools.api.models.ResourceUpdate<Update, UpdateAction, UpdateBuilder> {
035
036    /**
037     *
038     * @return version
039     */
040    @NotNull
041    @JsonProperty("version")
042    public Long getVersion();
043
044    /**
045     *
046     * @return actions
047     */
048    @NotNull
049    @Valid
050    @JsonProperty("actions")
051    public List<UpdateAction> getActions();
052
053    /**
054     * set version
055     * @param version value to be set
056     */
057
058    public void setVersion(final Long version);
059
060    /**
061     * set actions
062     * @param actions values to be set
063     */
064
065    @JsonIgnore
066    public void setActions(final UpdateAction... actions);
067
068    /**
069     * set actions
070     * @param actions values to be set
071     */
072
073    public void setActions(final List<UpdateAction> actions);
074
075    /**
076     * factory method
077     * @return instance of Update
078     */
079    public static Update of() {
080        return new UpdateImpl();
081    }
082
083    /**
084     * factory method to create a shallow copy Update
085     * @param template instance to be copied
086     * @return copy instance
087     */
088    public static Update of(final Update template) {
089        UpdateImpl instance = new UpdateImpl();
090        instance.setVersion(template.getVersion());
091        instance.setActions(template.getActions());
092        return instance;
093    }
094
095    /**
096     * factory method to create a deep copy of Update
097     * @param template instance to be copied
098     * @return copy instance
099     */
100    @Nullable
101    public static Update deepCopy(@Nullable final Update template) {
102        if (template == null) {
103            return null;
104        }
105        UpdateImpl instance = new UpdateImpl();
106        instance.setVersion(template.getVersion());
107        instance.setActions(Optional.ofNullable(template.getActions())
108                .map(t -> t.stream()
109                        .map(com.commercetools.api.models.common.UpdateAction::deepCopy)
110                        .collect(Collectors.toList()))
111                .orElse(null));
112        return instance;
113    }
114
115    /**
116     * builder factory method for Update
117     * @return builder
118     */
119    public static UpdateBuilder builder() {
120        return UpdateBuilder.of();
121    }
122
123    /**
124     * create builder for Update instance
125     * @param template instance with prefilled values for the builder
126     * @return builder
127     */
128    public static UpdateBuilder builder(final Update template) {
129        return UpdateBuilder.of(template);
130    }
131
132    /**
133     * accessor map function
134     * @param <T> mapped type
135     * @param helper function to map the object
136     * @return mapped value
137     */
138    default <T> T withUpdate(Function<Update, T> helper) {
139        return helper.apply(this);
140    }
141
142    /**
143     * gives a TypeReference for usage with Jackson DataBind
144     * @return TypeReference
145     */
146    public static com.fasterxml.jackson.core.type.TypeReference<Update> typeReference() {
147        return new com.fasterxml.jackson.core.type.TypeReference<Update>() {
148            @Override
149            public String toString() {
150                return "TypeReference<Update>";
151            }
152        };
153    }
154}