001
002package com.commercetools.api.models.shipping_method;
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 * ShippingMethodUpdate
020 *
021 * <hr>
022 * Example to create an instance using the builder pattern
023 * <div class=code-example>
024 * <pre><code class='java'>
025 *     ShippingMethodUpdate shippingMethodUpdate = ShippingMethodUpdate.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 = ShippingMethodUpdateImpl.class)
034public interface ShippingMethodUpdate extends
035        com.commercetools.api.models.ResourceUpdate<ShippingMethodUpdate, ShippingMethodUpdateAction, ShippingMethodUpdateBuilder> {
036
037    /**
038     *  <p>Expected version of the ShippingMethod 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 ShippingMethod.</p>
047     * @return actions
048     */
049    @NotNull
050    @Valid
051    @JsonProperty("actions")
052    public List<ShippingMethodUpdateAction> getActions();
053
054    /**
055     *  <p>Expected version of the ShippingMethod 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 ShippingMethod.</p>
063     * @param actions values to be set
064     */
065
066    @JsonIgnore
067    public void setActions(final ShippingMethodUpdateAction... actions);
068
069    /**
070     *  <p>Update actions to be performed on the ShippingMethod.</p>
071     * @param actions values to be set
072     */
073
074    public void setActions(final List<ShippingMethodUpdateAction> actions);
075
076    /**
077     * factory method
078     * @return instance of ShippingMethodUpdate
079     */
080    public static ShippingMethodUpdate of() {
081        return new ShippingMethodUpdateImpl();
082    }
083
084    /**
085     * factory method to create a shallow copy ShippingMethodUpdate
086     * @param template instance to be copied
087     * @return copy instance
088     */
089    public static ShippingMethodUpdate of(final ShippingMethodUpdate template) {
090        ShippingMethodUpdateImpl instance = new ShippingMethodUpdateImpl();
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 ShippingMethodUpdate
098     * @param template instance to be copied
099     * @return copy instance
100     */
101    @Nullable
102    public static ShippingMethodUpdate deepCopy(@Nullable final ShippingMethodUpdate template) {
103        if (template == null) {
104            return null;
105        }
106        ShippingMethodUpdateImpl instance = new ShippingMethodUpdateImpl();
107        instance.setVersion(template.getVersion());
108        instance.setActions(Optional.ofNullable(template.getActions())
109                .map(t -> t.stream()
110                        .map(com.commercetools.api.models.shipping_method.ShippingMethodUpdateAction::deepCopy)
111                        .collect(Collectors.toList()))
112                .orElse(null));
113        return instance;
114    }
115
116    /**
117     * builder factory method for ShippingMethodUpdate
118     * @return builder
119     */
120    public static ShippingMethodUpdateBuilder builder() {
121        return ShippingMethodUpdateBuilder.of();
122    }
123
124    /**
125     * create builder for ShippingMethodUpdate instance
126     * @param template instance with prefilled values for the builder
127     * @return builder
128     */
129    public static ShippingMethodUpdateBuilder builder(final ShippingMethodUpdate template) {
130        return ShippingMethodUpdateBuilder.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 withShippingMethodUpdate(Function<ShippingMethodUpdate, 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<ShippingMethodUpdate> typeReference() {
148        return new com.fasterxml.jackson.core.type.TypeReference<ShippingMethodUpdate>() {
149            @Override
150            public String toString() {
151                return "TypeReference<ShippingMethodUpdate>";
152            }
153        };
154    }
155}