001
002package com.commercetools.api.models.shipping_method;
003
004import java.time.*;
005import java.util.*;
006import java.util.function.Function;
007
008import javax.annotation.Nullable;
009import javax.validation.Valid;
010import javax.validation.constraints.NotNull;
011
012import com.commercetools.api.models.common.Money;
013import com.fasterxml.jackson.annotation.*;
014import com.fasterxml.jackson.databind.annotation.*;
015
016import io.vrap.rmf.base.client.utils.Generated;
017
018/**
019 *  <p>Used when the ShippingRate maps to an abstract Cart categorization expressed by integers (such as shipping scores or weight ranges). Either <code>price</code> or <code>priceFunction</code> is required.</p>
020 *
021 * <hr>
022 * Example to create an instance using the builder pattern
023 * <div class=code-example>
024 * <pre><code class='java'>
025 *     CartScoreTier cartScoreTier = CartScoreTier.builder()
026 *             .score(0.3)
027 *             .build()
028 * </code></pre>
029 * </div>
030 */
031@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen")
032@JsonDeserialize(as = CartScoreTierImpl.class)
033public interface CartScoreTier extends ShippingRatePriceTier {
034
035    /**
036     * discriminator value for CartScoreTier
037     */
038    String CART_SCORE = "CartScore";
039
040    /**
041     *  <p>Abstract value for categorizing a Cart. The range starts at <code>0</code>. The default price covers <code>0</code>, tiers start at <code>1</code>. See Using Tiered Shipping Rates for details and examples.</p>
042     * @return score
043     */
044    @NotNull
045    @JsonProperty("score")
046    public Integer getScore();
047
048    /**
049     *  <p>Defines a fixed price for the <code>score</code>.</p>
050     * @return price
051     */
052    @Valid
053    @JsonProperty("price")
054    public Money getPrice();
055
056    /**
057     *  <p>Dynamically calculates a Price for a range of scores.</p>
058     * @return priceFunction
059     */
060    @Valid
061    @JsonProperty("priceFunction")
062    public PriceFunction getPriceFunction();
063
064    /**
065     *  <p>Appears in response to Get ShippingMethods for a Cart if the shipping rate matches the search query.</p>
066     * @return isMatching
067     */
068
069    @JsonProperty("isMatching")
070    public Boolean getIsMatching();
071
072    /**
073     *  <p>Abstract value for categorizing a Cart. The range starts at <code>0</code>. The default price covers <code>0</code>, tiers start at <code>1</code>. See Using Tiered Shipping Rates for details and examples.</p>
074     * @param score value to be set
075     */
076
077    public void setScore(final Integer score);
078
079    /**
080     *  <p>Defines a fixed price for the <code>score</code>.</p>
081     * @param price value to be set
082     */
083
084    public void setPrice(final Money price);
085
086    /**
087     *  <p>Dynamically calculates a Price for a range of scores.</p>
088     * @param priceFunction value to be set
089     */
090
091    public void setPriceFunction(final PriceFunction priceFunction);
092
093    /**
094     *  <p>Appears in response to Get ShippingMethods for a Cart if the shipping rate matches the search query.</p>
095     * @param isMatching value to be set
096     */
097
098    public void setIsMatching(final Boolean isMatching);
099
100    /**
101     * factory method
102     * @return instance of CartScoreTier
103     */
104    public static CartScoreTier of() {
105        return new CartScoreTierImpl();
106    }
107
108    /**
109     * factory method to create a shallow copy CartScoreTier
110     * @param template instance to be copied
111     * @return copy instance
112     */
113    public static CartScoreTier of(final CartScoreTier template) {
114        CartScoreTierImpl instance = new CartScoreTierImpl();
115        instance.setScore(template.getScore());
116        instance.setPrice(template.getPrice());
117        instance.setPriceFunction(template.getPriceFunction());
118        instance.setIsMatching(template.getIsMatching());
119        return instance;
120    }
121
122    /**
123     * factory method to create a deep copy of CartScoreTier
124     * @param template instance to be copied
125     * @return copy instance
126     */
127    @Nullable
128    public static CartScoreTier deepCopy(@Nullable final CartScoreTier template) {
129        if (template == null) {
130            return null;
131        }
132        CartScoreTierImpl instance = new CartScoreTierImpl();
133        instance.setScore(template.getScore());
134        instance.setPrice(com.commercetools.api.models.common.Money.deepCopy(template.getPrice()));
135        instance.setPriceFunction(
136            com.commercetools.api.models.shipping_method.PriceFunction.deepCopy(template.getPriceFunction()));
137        instance.setIsMatching(template.getIsMatching());
138        return instance;
139    }
140
141    /**
142     * builder factory method for CartScoreTier
143     * @return builder
144     */
145    public static CartScoreTierBuilder builder() {
146        return CartScoreTierBuilder.of();
147    }
148
149    /**
150     * create builder for CartScoreTier instance
151     * @param template instance with prefilled values for the builder
152     * @return builder
153     */
154    public static CartScoreTierBuilder builder(final CartScoreTier template) {
155        return CartScoreTierBuilder.of(template);
156    }
157
158    /**
159     * accessor map function
160     * @param <T> mapped type
161     * @param helper function to map the object
162     * @return mapped value
163     */
164    default <T> T withCartScoreTier(Function<CartScoreTier, T> helper) {
165        return helper.apply(this);
166    }
167
168    /**
169     * gives a TypeReference for usage with Jackson DataBind
170     * @return TypeReference
171     */
172    public static com.fasterxml.jackson.core.type.TypeReference<CartScoreTier> typeReference() {
173        return new com.fasterxml.jackson.core.type.TypeReference<CartScoreTier>() {
174            @Override
175            public String toString() {
176                return "TypeReference<CartScoreTier>";
177            }
178        };
179    }
180}