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.commercetools.api.models.zone.ZoneResourceIdentifier;
014import com.fasterxml.jackson.annotation.*;
015import com.fasterxml.jackson.databind.annotation.*;
016
017import io.vrap.rmf.base.client.utils.Generated;
018
019/**
020 * ZoneRateDraft
021 *
022 * <hr>
023 * Example to create an instance using the builder pattern
024 * <div class=code-example>
025 * <pre><code class='java'>
026 *     ZoneRateDraft zoneRateDraft = ZoneRateDraft.builder()
027 *             .zone(zoneBuilder -> zoneBuilder)
028 *             .plusShippingRates(shippingRatesBuilder -> shippingRatesBuilder)
029 *             .build()
030 * </code></pre>
031 * </div>
032 */
033@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen")
034@JsonDeserialize(as = ZoneRateDraftImpl.class)
035public interface ZoneRateDraft extends io.vrap.rmf.base.client.Draft<ZoneRateDraft> {
036
037    /**
038     *  <p>Sets the Zone for which the shippng rates are valid.</p>
039     * @return zone
040     */
041    @NotNull
042    @Valid
043    @JsonProperty("zone")
044    public ZoneResourceIdentifier getZone();
045
046    /**
047     *  <p>Shipping rates for the <code>currencies</code> configured in the Project. The array must not contain two ShippingRates with the same CurrencyCode.</p>
048     * @return shippingRates
049     */
050    @NotNull
051    @Valid
052    @JsonProperty("shippingRates")
053    public List<ShippingRateDraft> getShippingRates();
054
055    /**
056     *  <p>Sets the Zone for which the shippng rates are valid.</p>
057     * @param zone value to be set
058     */
059
060    public void setZone(final ZoneResourceIdentifier zone);
061
062    /**
063     *  <p>Shipping rates for the <code>currencies</code> configured in the Project. The array must not contain two ShippingRates with the same CurrencyCode.</p>
064     * @param shippingRates values to be set
065     */
066
067    @JsonIgnore
068    public void setShippingRates(final ShippingRateDraft... shippingRates);
069
070    /**
071     *  <p>Shipping rates for the <code>currencies</code> configured in the Project. The array must not contain two ShippingRates with the same CurrencyCode.</p>
072     * @param shippingRates values to be set
073     */
074
075    public void setShippingRates(final List<ShippingRateDraft> shippingRates);
076
077    /**
078     * factory method
079     * @return instance of ZoneRateDraft
080     */
081    public static ZoneRateDraft of() {
082        return new ZoneRateDraftImpl();
083    }
084
085    /**
086     * factory method to create a shallow copy ZoneRateDraft
087     * @param template instance to be copied
088     * @return copy instance
089     */
090    public static ZoneRateDraft of(final ZoneRateDraft template) {
091        ZoneRateDraftImpl instance = new ZoneRateDraftImpl();
092        instance.setZone(template.getZone());
093        instance.setShippingRates(template.getShippingRates());
094        return instance;
095    }
096
097    /**
098     * factory method to create a deep copy of ZoneRateDraft
099     * @param template instance to be copied
100     * @return copy instance
101     */
102    @Nullable
103    public static ZoneRateDraft deepCopy(@Nullable final ZoneRateDraft template) {
104        if (template == null) {
105            return null;
106        }
107        ZoneRateDraftImpl instance = new ZoneRateDraftImpl();
108        instance.setZone(com.commercetools.api.models.zone.ZoneResourceIdentifier.deepCopy(template.getZone()));
109        instance.setShippingRates(Optional.ofNullable(template.getShippingRates())
110                .map(t -> t.stream()
111                        .map(com.commercetools.api.models.shipping_method.ShippingRateDraft::deepCopy)
112                        .collect(Collectors.toList()))
113                .orElse(null));
114        return instance;
115    }
116
117    /**
118     * builder factory method for ZoneRateDraft
119     * @return builder
120     */
121    public static ZoneRateDraftBuilder builder() {
122        return ZoneRateDraftBuilder.of();
123    }
124
125    /**
126     * create builder for ZoneRateDraft instance
127     * @param template instance with prefilled values for the builder
128     * @return builder
129     */
130    public static ZoneRateDraftBuilder builder(final ZoneRateDraft template) {
131        return ZoneRateDraftBuilder.of(template);
132    }
133
134    /**
135     * accessor map function
136     * @param <T> mapped type
137     * @param helper function to map the object
138     * @return mapped value
139     */
140    default <T> T withZoneRateDraft(Function<ZoneRateDraft, T> helper) {
141        return helper.apply(this);
142    }
143
144    /**
145     * gives a TypeReference for usage with Jackson DataBind
146     * @return TypeReference
147     */
148    public static com.fasterxml.jackson.core.type.TypeReference<ZoneRateDraft> typeReference() {
149        return new com.fasterxml.jackson.core.type.TypeReference<ZoneRateDraft>() {
150            @Override
151            public String toString() {
152                return "TypeReference<ZoneRateDraft>";
153            }
154        };
155    }
156}