001
002package com.commercetools.history.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 * ShippingRate
020 *
021 * <hr>
022 * Example to create an instance using the builder pattern
023 * <div class=code-example>
024 * <pre><code class='java'>
025 *     ShippingRate shippingRate = ShippingRate.builder()
026 *             .price(priceBuilder -> priceBuilder)
027 *             .freeAbove(freeAboveBuilder -> freeAboveBuilder)
028 *             .isMatching(true)
029 *             .plusTiers(tiersBuilder -> tiersBuilder)
030 *             .build()
031 * </code></pre>
032 * </div>
033 */
034@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen")
035@JsonDeserialize(as = ShippingRateImpl.class)
036public interface ShippingRate {
037
038    /**
039     *
040     * @return price
041     */
042    @NotNull
043    @Valid
044    @JsonProperty("price")
045    public Money getPrice();
046
047    /**
048     *
049     * @return freeAbove
050     */
051    @NotNull
052    @Valid
053    @JsonProperty("freeAbove")
054    public Money getFreeAbove();
055
056    /**
057     *  <p>Only appears in response to requests for ShippingMethods by Cart or location to mark this shipping rate as one that matches the Cart or location.</p>
058     * @return isMatching
059     */
060    @NotNull
061    @JsonProperty("isMatching")
062    public Boolean getIsMatching();
063
064    /**
065     *
066     * @return tiers
067     */
068    @NotNull
069    @Valid
070    @JsonProperty("tiers")
071    public List<ShippingRatePriceTier> getTiers();
072
073    /**
074     * set price
075     * @param price value to be set
076     */
077
078    public void setPrice(final Money price);
079
080    /**
081     * set freeAbove
082     * @param freeAbove value to be set
083     */
084
085    public void setFreeAbove(final Money freeAbove);
086
087    /**
088     *  <p>Only appears in response to requests for ShippingMethods by Cart or location to mark this shipping rate as one that matches the Cart or location.</p>
089     * @param isMatching value to be set
090     */
091
092    public void setIsMatching(final Boolean isMatching);
093
094    /**
095     * set tiers
096     * @param tiers values to be set
097     */
098
099    @JsonIgnore
100    public void setTiers(final ShippingRatePriceTier... tiers);
101
102    /**
103     * set tiers
104     * @param tiers values to be set
105     */
106
107    public void setTiers(final List<ShippingRatePriceTier> tiers);
108
109    /**
110     * factory method
111     * @return instance of ShippingRate
112     */
113    public static ShippingRate of() {
114        return new ShippingRateImpl();
115    }
116
117    /**
118     * factory method to create a shallow copy ShippingRate
119     * @param template instance to be copied
120     * @return copy instance
121     */
122    public static ShippingRate of(final ShippingRate template) {
123        ShippingRateImpl instance = new ShippingRateImpl();
124        instance.setPrice(template.getPrice());
125        instance.setFreeAbove(template.getFreeAbove());
126        instance.setIsMatching(template.getIsMatching());
127        instance.setTiers(template.getTiers());
128        return instance;
129    }
130
131    /**
132     * factory method to create a deep copy of ShippingRate
133     * @param template instance to be copied
134     * @return copy instance
135     */
136    @Nullable
137    public static ShippingRate deepCopy(@Nullable final ShippingRate template) {
138        if (template == null) {
139            return null;
140        }
141        ShippingRateImpl instance = new ShippingRateImpl();
142        instance.setPrice(com.commercetools.history.models.common.Money.deepCopy(template.getPrice()));
143        instance.setFreeAbove(com.commercetools.history.models.common.Money.deepCopy(template.getFreeAbove()));
144        instance.setIsMatching(template.getIsMatching());
145        instance.setTiers(Optional.ofNullable(template.getTiers())
146                .map(t -> t.stream()
147                        .map(com.commercetools.history.models.common.ShippingRatePriceTier::deepCopy)
148                        .collect(Collectors.toList()))
149                .orElse(null));
150        return instance;
151    }
152
153    /**
154     * builder factory method for ShippingRate
155     * @return builder
156     */
157    public static ShippingRateBuilder builder() {
158        return ShippingRateBuilder.of();
159    }
160
161    /**
162     * create builder for ShippingRate instance
163     * @param template instance with prefilled values for the builder
164     * @return builder
165     */
166    public static ShippingRateBuilder builder(final ShippingRate template) {
167        return ShippingRateBuilder.of(template);
168    }
169
170    /**
171     * accessor map function
172     * @param <T> mapped type
173     * @param helper function to map the object
174     * @return mapped value
175     */
176    default <T> T withShippingRate(Function<ShippingRate, T> helper) {
177        return helper.apply(this);
178    }
179
180    /**
181     * gives a TypeReference for usage with Jackson DataBind
182     * @return TypeReference
183     */
184    public static com.fasterxml.jackson.core.type.TypeReference<ShippingRate> typeReference() {
185        return new com.fasterxml.jackson.core.type.TypeReference<ShippingRate>() {
186            @Override
187            public String toString() {
188                return "TypeReference<ShippingRate>";
189            }
190        };
191    }
192}