001
002package com.commercetools.api.models.cart;
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.common.CentPrecisionMoney;
014import com.commercetools.api.models.common.LocalizedString;
015import com.commercetools.api.models.common.TypedMoney;
016import com.commercetools.api.models.order.ItemState;
017import com.commercetools.api.models.tax_category.TaxCategoryReference;
018import com.commercetools.api.models.tax_category.TaxRate;
019import com.commercetools.api.models.type.CustomFields;
020import com.fasterxml.jackson.annotation.*;
021import com.fasterxml.jackson.databind.annotation.*;
022
023import io.vrap.rmf.base.client.utils.Generated;
024
025/**
026 *  <p>A generic item that can be added to the Cart but is not bound to a Product that can be used for discounts (negative money), vouchers, complex cart rules, additional services, or fees. You control the lifecycle of this item.</p>
027 *
028 * <hr>
029 * Example to create an instance using the builder pattern
030 * <div class=code-example>
031 * <pre><code class='java'>
032 *     CustomLineItem customLineItem = CustomLineItem.builder()
033 *             .id("{id}")
034 *             .name(nameBuilder -> nameBuilder)
035 *             .money(moneyBuilder -> moneyBuilder)
036 *             .totalPrice(totalPriceBuilder -> totalPriceBuilder)
037 *             .slug("{slug}")
038 *             .quantity(0.3)
039 *             .plusState(stateBuilder -> stateBuilder)
040 *             .plusDiscountedPricePerQuantity(discountedPricePerQuantityBuilder -> discountedPricePerQuantityBuilder)
041 *             .priceMode(CustomLineItemPriceMode.STANDARD)
042 *             .build()
043 * </code></pre>
044 * </div>
045 */
046@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen")
047@JsonDeserialize(as = CustomLineItemImpl.class)
048public interface CustomLineItem extends com.commercetools.api.models.Customizable<CustomLineItem> {
049
050    /**
051     *  <p>Unique identifier of the Custom Line Item.</p>
052     * @return id
053     */
054    @NotNull
055    @JsonProperty("id")
056    public String getId();
057
058    /**
059     *  <p>Name of the Custom Line Item.</p>
060     * @return name
061     */
062    @NotNull
063    @Valid
064    @JsonProperty("name")
065    public LocalizedString getName();
066
067    /**
068     *  <p>Money value of the Custom Line Item.</p>
069     * @return money
070     */
071    @NotNull
072    @Valid
073    @JsonProperty("money")
074    public TypedMoney getMoney();
075
076    /**
077     *  <p>Automatically set after the <code>taxRate</code> is set.</p>
078     * @return taxedPrice
079     */
080    @Valid
081    @JsonProperty("taxedPrice")
082    public TaxedItemPrice getTaxedPrice();
083
084    /**
085     *  <p>Total price of the Custom Line Item (<code>money</code> multiplied by <code>quantity</code>). If the Custom Line Item is discounted, the total price is <code>discountedPricePerQuantity</code> multiplied by <code>quantity</code>.</p>
086     *  <p>Includes taxes if the TaxRate <code>includedInPrice</code> is <code>true</code>.</p>
087     * @return totalPrice
088     */
089    @NotNull
090    @Valid
091    @JsonProperty("totalPrice")
092    public CentPrecisionMoney getTotalPrice();
093
094    /**
095     *  <p>User-defined identifier used in a deep-link URL for the Custom Line Item. It matches the pattern <code>[a-zA-Z0-9_-]{2,256}</code>.</p>
096     * @return slug
097     */
098    @NotNull
099    @JsonProperty("slug")
100    public String getSlug();
101
102    /**
103     *  <p>Number of Custom Line Items in the Cart.</p>
104     * @return quantity
105     */
106    @NotNull
107    @JsonProperty("quantity")
108    public Long getQuantity();
109
110    /**
111     *  <p>State of the Custom Line Item in the Cart.</p>
112     * @return state
113     */
114    @NotNull
115    @Valid
116    @JsonProperty("state")
117    public List<ItemState> getState();
118
119    /**
120     *  <p>Used to select a Tax Rate when a Cart has the <code>Platform</code> TaxMode.</p>
121     * @return taxCategory
122     */
123    @Valid
124    @JsonProperty("taxCategory")
125    public TaxCategoryReference getTaxCategory();
126
127    /**
128     *  <ul>
129     *   <li>For a Cart with <code>Platform</code> TaxMode, the <code>taxRate</code> of Custom Line Items is set automatically once a shipping address is set. The rate is based on the TaxCategory that applies for the shipping address.</li>
130     *   <li>For a Cart with <code>External</code> TaxMode, the <code>taxRate</code> of Custom Line Items can be set using ExternalTaxRateDraft.</li>
131     *  </ul>
132     * @return taxRate
133     */
134    @Valid
135    @JsonProperty("taxRate")
136    public TaxRate getTaxRate();
137
138    /**
139     *  <p>Discounted price of a single quantity of the Custom Line Item.</p>
140     * @return discountedPricePerQuantity
141     */
142    @NotNull
143    @Valid
144    @JsonProperty("discountedPricePerQuantity")
145    public List<DiscountedLineItemPriceForQuantity> getDiscountedPricePerQuantity();
146
147    /**
148     *  <p>Custom Fields of the Custom Line Item.</p>
149     * @return custom
150     */
151    @Valid
152    @JsonProperty("custom")
153    public CustomFields getCustom();
154
155    /**
156     *  <p>Container for Custom Line Item-specific addresses.</p>
157     * @return shippingDetails
158     */
159    @Valid
160    @JsonProperty("shippingDetails")
161    public ItemShippingDetails getShippingDetails();
162
163    /**
164     *  <p>Indicates whether Cart Discounts with a matching CartDiscountCustomLineItemsTarget are applied to the Custom Line Item.</p>
165     * @return priceMode
166     */
167    @NotNull
168    @JsonProperty("priceMode")
169    public CustomLineItemPriceMode getPriceMode();
170
171    /**
172     *  <p>Unique identifier of the Custom Line Item.</p>
173     * @param id value to be set
174     */
175
176    public void setId(final String id);
177
178    /**
179     *  <p>Name of the Custom Line Item.</p>
180     * @param name value to be set
181     */
182
183    public void setName(final LocalizedString name);
184
185    /**
186     *  <p>Money value of the Custom Line Item.</p>
187     * @param money value to be set
188     */
189
190    public void setMoney(final TypedMoney money);
191
192    /**
193     *  <p>Automatically set after the <code>taxRate</code> is set.</p>
194     * @param taxedPrice value to be set
195     */
196
197    public void setTaxedPrice(final TaxedItemPrice taxedPrice);
198
199    /**
200     *  <p>Total price of the Custom Line Item (<code>money</code> multiplied by <code>quantity</code>). If the Custom Line Item is discounted, the total price is <code>discountedPricePerQuantity</code> multiplied by <code>quantity</code>.</p>
201     *  <p>Includes taxes if the TaxRate <code>includedInPrice</code> is <code>true</code>.</p>
202     * @param totalPrice value to be set
203     */
204
205    public void setTotalPrice(final CentPrecisionMoney totalPrice);
206
207    /**
208     *  <p>User-defined identifier used in a deep-link URL for the Custom Line Item. It matches the pattern <code>[a-zA-Z0-9_-]{2,256}</code>.</p>
209     * @param slug value to be set
210     */
211
212    public void setSlug(final String slug);
213
214    /**
215     *  <p>Number of Custom Line Items in the Cart.</p>
216     * @param quantity value to be set
217     */
218
219    public void setQuantity(final Long quantity);
220
221    /**
222     *  <p>State of the Custom Line Item in the Cart.</p>
223     * @param state values to be set
224     */
225
226    @JsonIgnore
227    public void setState(final ItemState... state);
228
229    /**
230     *  <p>State of the Custom Line Item in the Cart.</p>
231     * @param state values to be set
232     */
233
234    public void setState(final List<ItemState> state);
235
236    /**
237     *  <p>Used to select a Tax Rate when a Cart has the <code>Platform</code> TaxMode.</p>
238     * @param taxCategory value to be set
239     */
240
241    public void setTaxCategory(final TaxCategoryReference taxCategory);
242
243    /**
244     *  <ul>
245     *   <li>For a Cart with <code>Platform</code> TaxMode, the <code>taxRate</code> of Custom Line Items is set automatically once a shipping address is set. The rate is based on the TaxCategory that applies for the shipping address.</li>
246     *   <li>For a Cart with <code>External</code> TaxMode, the <code>taxRate</code> of Custom Line Items can be set using ExternalTaxRateDraft.</li>
247     *  </ul>
248     * @param taxRate value to be set
249     */
250
251    public void setTaxRate(final TaxRate taxRate);
252
253    /**
254     *  <p>Discounted price of a single quantity of the Custom Line Item.</p>
255     * @param discountedPricePerQuantity values to be set
256     */
257
258    @JsonIgnore
259    public void setDiscountedPricePerQuantity(final DiscountedLineItemPriceForQuantity... discountedPricePerQuantity);
260
261    /**
262     *  <p>Discounted price of a single quantity of the Custom Line Item.</p>
263     * @param discountedPricePerQuantity values to be set
264     */
265
266    public void setDiscountedPricePerQuantity(
267            final List<DiscountedLineItemPriceForQuantity> discountedPricePerQuantity);
268
269    /**
270     *  <p>Custom Fields of the Custom Line Item.</p>
271     * @param custom value to be set
272     */
273
274    public void setCustom(final CustomFields custom);
275
276    /**
277     *  <p>Container for Custom Line Item-specific addresses.</p>
278     * @param shippingDetails value to be set
279     */
280
281    public void setShippingDetails(final ItemShippingDetails shippingDetails);
282
283    /**
284     *  <p>Indicates whether Cart Discounts with a matching CartDiscountCustomLineItemsTarget are applied to the Custom Line Item.</p>
285     * @param priceMode value to be set
286     */
287
288    public void setPriceMode(final CustomLineItemPriceMode priceMode);
289
290    /**
291     * factory method
292     * @return instance of CustomLineItem
293     */
294    public static CustomLineItem of() {
295        return new CustomLineItemImpl();
296    }
297
298    /**
299     * factory method to create a shallow copy CustomLineItem
300     * @param template instance to be copied
301     * @return copy instance
302     */
303    public static CustomLineItem of(final CustomLineItem template) {
304        CustomLineItemImpl instance = new CustomLineItemImpl();
305        instance.setId(template.getId());
306        instance.setName(template.getName());
307        instance.setMoney(template.getMoney());
308        instance.setTaxedPrice(template.getTaxedPrice());
309        instance.setTotalPrice(template.getTotalPrice());
310        instance.setSlug(template.getSlug());
311        instance.setQuantity(template.getQuantity());
312        instance.setState(template.getState());
313        instance.setTaxCategory(template.getTaxCategory());
314        instance.setTaxRate(template.getTaxRate());
315        instance.setDiscountedPricePerQuantity(template.getDiscountedPricePerQuantity());
316        instance.setCustom(template.getCustom());
317        instance.setShippingDetails(template.getShippingDetails());
318        instance.setPriceMode(template.getPriceMode());
319        return instance;
320    }
321
322    /**
323     * factory method to create a deep copy of CustomLineItem
324     * @param template instance to be copied
325     * @return copy instance
326     */
327    @Nullable
328    public static CustomLineItem deepCopy(@Nullable final CustomLineItem template) {
329        if (template == null) {
330            return null;
331        }
332        CustomLineItemImpl instance = new CustomLineItemImpl();
333        instance.setId(template.getId());
334        instance.setName(com.commercetools.api.models.common.LocalizedString.deepCopy(template.getName()));
335        instance.setMoney(com.commercetools.api.models.common.TypedMoney.deepCopy(template.getMoney()));
336        instance.setTaxedPrice(com.commercetools.api.models.cart.TaxedItemPrice.deepCopy(template.getTaxedPrice()));
337        instance.setTotalPrice(
338            com.commercetools.api.models.common.CentPrecisionMoney.deepCopy(template.getTotalPrice()));
339        instance.setSlug(template.getSlug());
340        instance.setQuantity(template.getQuantity());
341        instance.setState(Optional.ofNullable(template.getState())
342                .map(t -> t.stream()
343                        .map(com.commercetools.api.models.order.ItemState::deepCopy)
344                        .collect(Collectors.toList()))
345                .orElse(null));
346        instance.setTaxCategory(
347            com.commercetools.api.models.tax_category.TaxCategoryReference.deepCopy(template.getTaxCategory()));
348        instance.setTaxRate(com.commercetools.api.models.tax_category.TaxRate.deepCopy(template.getTaxRate()));
349        instance.setDiscountedPricePerQuantity(Optional.ofNullable(template.getDiscountedPricePerQuantity())
350                .map(t -> t.stream()
351                        .map(com.commercetools.api.models.cart.DiscountedLineItemPriceForQuantity::deepCopy)
352                        .collect(Collectors.toList()))
353                .orElse(null));
354        instance.setCustom(com.commercetools.api.models.type.CustomFields.deepCopy(template.getCustom()));
355        instance.setShippingDetails(
356            com.commercetools.api.models.cart.ItemShippingDetails.deepCopy(template.getShippingDetails()));
357        instance.setPriceMode(template.getPriceMode());
358        return instance;
359    }
360
361    /**
362     * builder factory method for CustomLineItem
363     * @return builder
364     */
365    public static CustomLineItemBuilder builder() {
366        return CustomLineItemBuilder.of();
367    }
368
369    /**
370     * create builder for CustomLineItem instance
371     * @param template instance with prefilled values for the builder
372     * @return builder
373     */
374    public static CustomLineItemBuilder builder(final CustomLineItem template) {
375        return CustomLineItemBuilder.of(template);
376    }
377
378    /**
379     * accessor map function
380     * @param <T> mapped type
381     * @param helper function to map the object
382     * @return mapped value
383     */
384    default <T> T withCustomLineItem(Function<CustomLineItem, T> helper) {
385        return helper.apply(this);
386    }
387
388    /**
389     * gives a TypeReference for usage with Jackson DataBind
390     * @return TypeReference
391     */
392    public static com.fasterxml.jackson.core.type.TypeReference<CustomLineItem> typeReference() {
393        return new com.fasterxml.jackson.core.type.TypeReference<CustomLineItem>() {
394            @Override
395            public String toString() {
396                return "TypeReference<CustomLineItem>";
397            }
398        };
399    }
400}