001
002package com.commercetools.importapi.models.orders;
003
004import java.time.*;
005import java.time.ZonedDateTime;
006import java.util.*;
007import java.util.function.Function;
008import java.util.stream.Collectors;
009
010import javax.annotation.Nullable;
011import javax.validation.Valid;
012import javax.validation.constraints.NotNull;
013
014import com.commercetools.importapi.models.common.ChannelKeyReference;
015import com.commercetools.importapi.models.common.CustomerGroupKeyReference;
016import com.commercetools.importapi.models.common.DiscountedPrice;
017import com.commercetools.importapi.models.common.PriceTier;
018import com.commercetools.importapi.models.common.TypedMoney;
019import com.commercetools.importapi.models.customfields.Custom;
020import com.fasterxml.jackson.annotation.*;
021import com.fasterxml.jackson.databind.annotation.*;
022
023import io.vrap.rmf.base.client.utils.Generated;
024
025/**
026 * LineItemPrice
027 *
028 * <hr>
029 * Example to create an instance using the builder pattern
030 * <div class=code-example>
031 * <pre><code class='java'>
032 *     LineItemPrice lineItemPrice = LineItemPrice.builder()
033 *             .value(valueBuilder -> valueBuilder)
034 *             .build()
035 * </code></pre>
036 * </div>
037 */
038@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen")
039@JsonDeserialize(as = LineItemPriceImpl.class)
040public interface LineItemPrice {
041
042    /**
043     *  <p>Maps to <code>Price.value</code>.</p>
044     * @return value
045     */
046    @NotNull
047    @Valid
048    @JsonProperty("value")
049    public TypedMoney getValue();
050
051    /**
052     *  <p>Maps to <code>Price.county</code>.</p>
053     * @return country
054     */
055
056    @JsonProperty("country")
057    public String getCountry();
058
059    /**
060     *  <p>Maps to <code>Price.validFrom</code>.</p>
061     * @return validFrom
062     */
063
064    @JsonProperty("validFrom")
065    public ZonedDateTime getValidFrom();
066
067    /**
068     *  <p>Maps to <code>Price.validUntil</code>.</p>
069     * @return validUntil
070     */
071
072    @JsonProperty("validUntil")
073    public ZonedDateTime getValidUntil();
074
075    /**
076     *  <p>References a customer group by key.</p>
077     * @return customerGroup
078     */
079    @Valid
080    @JsonProperty("customerGroup")
081    public CustomerGroupKeyReference getCustomerGroup();
082
083    /**
084     *  <p>References a channel by key.</p>
085     * @return channel
086     */
087    @Valid
088    @JsonProperty("channel")
089    public ChannelKeyReference getChannel();
090
091    /**
092     *  <p>Sets a discounted price from an external service.</p>
093     * @return discounted
094     */
095    @Valid
096    @JsonProperty("discounted")
097    public DiscountedPrice getDiscounted();
098
099    /**
100     *  <p>The tiered prices for this price.</p>
101     * @return tiers
102     */
103    @Valid
104    @JsonProperty("tiers")
105    public List<PriceTier> getTiers();
106
107    /**
108     *  <p>Maps to <code>Price.custom</code>.</p>
109     * @return custom
110     */
111    @Valid
112    @JsonProperty("custom")
113    public Custom getCustom();
114
115    /**
116     *  <p>Maps to <code>Price.value</code>.</p>
117     * @param value value to be set
118     */
119
120    public void setValue(final TypedMoney value);
121
122    /**
123     *  <p>Maps to <code>Price.county</code>.</p>
124     * @param country value to be set
125     */
126
127    public void setCountry(final String country);
128
129    /**
130     *  <p>Maps to <code>Price.validFrom</code>.</p>
131     * @param validFrom value to be set
132     */
133
134    public void setValidFrom(final ZonedDateTime validFrom);
135
136    /**
137     *  <p>Maps to <code>Price.validUntil</code>.</p>
138     * @param validUntil value to be set
139     */
140
141    public void setValidUntil(final ZonedDateTime validUntil);
142
143    /**
144     *  <p>References a customer group by key.</p>
145     * @param customerGroup value to be set
146     */
147
148    public void setCustomerGroup(final CustomerGroupKeyReference customerGroup);
149
150    /**
151     *  <p>References a channel by key.</p>
152     * @param channel value to be set
153     */
154
155    public void setChannel(final ChannelKeyReference channel);
156
157    /**
158     *  <p>Sets a discounted price from an external service.</p>
159     * @param discounted value to be set
160     */
161
162    public void setDiscounted(final DiscountedPrice discounted);
163
164    /**
165     *  <p>The tiered prices for this price.</p>
166     * @param tiers values to be set
167     */
168
169    @JsonIgnore
170    public void setTiers(final PriceTier... tiers);
171
172    /**
173     *  <p>The tiered prices for this price.</p>
174     * @param tiers values to be set
175     */
176
177    public void setTiers(final List<PriceTier> tiers);
178
179    /**
180     *  <p>Maps to <code>Price.custom</code>.</p>
181     * @param custom value to be set
182     */
183
184    public void setCustom(final Custom custom);
185
186    /**
187     * factory method
188     * @return instance of LineItemPrice
189     */
190    public static LineItemPrice of() {
191        return new LineItemPriceImpl();
192    }
193
194    /**
195     * factory method to create a shallow copy LineItemPrice
196     * @param template instance to be copied
197     * @return copy instance
198     */
199    public static LineItemPrice of(final LineItemPrice template) {
200        LineItemPriceImpl instance = new LineItemPriceImpl();
201        instance.setValue(template.getValue());
202        instance.setCountry(template.getCountry());
203        instance.setValidFrom(template.getValidFrom());
204        instance.setValidUntil(template.getValidUntil());
205        instance.setCustomerGroup(template.getCustomerGroup());
206        instance.setChannel(template.getChannel());
207        instance.setDiscounted(template.getDiscounted());
208        instance.setTiers(template.getTiers());
209        instance.setCustom(template.getCustom());
210        return instance;
211    }
212
213    /**
214     * factory method to create a deep copy of LineItemPrice
215     * @param template instance to be copied
216     * @return copy instance
217     */
218    @Nullable
219    public static LineItemPrice deepCopy(@Nullable final LineItemPrice template) {
220        if (template == null) {
221            return null;
222        }
223        LineItemPriceImpl instance = new LineItemPriceImpl();
224        instance.setValue(com.commercetools.importapi.models.common.TypedMoney.deepCopy(template.getValue()));
225        instance.setCountry(template.getCountry());
226        instance.setValidFrom(template.getValidFrom());
227        instance.setValidUntil(template.getValidUntil());
228        instance.setCustomerGroup(
229            com.commercetools.importapi.models.common.CustomerGroupKeyReference.deepCopy(template.getCustomerGroup()));
230        instance.setChannel(
231            com.commercetools.importapi.models.common.ChannelKeyReference.deepCopy(template.getChannel()));
232        instance.setDiscounted(
233            com.commercetools.importapi.models.common.DiscountedPrice.deepCopy(template.getDiscounted()));
234        instance.setTiers(Optional.ofNullable(template.getTiers())
235                .map(t -> t.stream()
236                        .map(com.commercetools.importapi.models.common.PriceTier::deepCopy)
237                        .collect(Collectors.toList()))
238                .orElse(null));
239        instance.setCustom(com.commercetools.importapi.models.customfields.Custom.deepCopy(template.getCustom()));
240        return instance;
241    }
242
243    /**
244     * builder factory method for LineItemPrice
245     * @return builder
246     */
247    public static LineItemPriceBuilder builder() {
248        return LineItemPriceBuilder.of();
249    }
250
251    /**
252     * create builder for LineItemPrice instance
253     * @param template instance with prefilled values for the builder
254     * @return builder
255     */
256    public static LineItemPriceBuilder builder(final LineItemPrice template) {
257        return LineItemPriceBuilder.of(template);
258    }
259
260    /**
261     * accessor map function
262     * @param <T> mapped type
263     * @param helper function to map the object
264     * @return mapped value
265     */
266    default <T> T withLineItemPrice(Function<LineItemPrice, T> helper) {
267        return helper.apply(this);
268    }
269
270    /**
271     * gives a TypeReference for usage with Jackson DataBind
272     * @return TypeReference
273     */
274    public static com.fasterxml.jackson.core.type.TypeReference<LineItemPrice> typeReference() {
275        return new com.fasterxml.jackson.core.type.TypeReference<LineItemPrice>() {
276            @Override
277            public String toString() {
278                return "TypeReference<LineItemPrice>";
279            }
280        };
281    }
282}