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 * ItemShippingDetails
020 *
021 * <hr>
022 * Example to create an instance using the builder pattern
023 * <div class=code-example>
024 * <pre><code class='java'>
025 *     ItemShippingDetails itemShippingDetails = ItemShippingDetails.builder()
026 *             .plusTargets(targetsBuilder -> targetsBuilder)
027 *             .valid(true)
028 *             .build()
029 * </code></pre>
030 * </div>
031 */
032@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen")
033@JsonDeserialize(as = ItemShippingDetailsImpl.class)
034public interface ItemShippingDetails {
035
036    /**
037     *
038     * @return targets
039     */
040    @NotNull
041    @Valid
042    @JsonProperty("targets")
043    public List<ItemShippingTarget> getTargets();
044
045    /**
046     *  <p>true if the quantity of the (custom) line item is equal to the sum of the sub-quantities in <code>targets</code>, <code>false</code> otherwise. A cart cannot be ordered when the value is <code>false</code>. The error InvalidItemShippingDetails will be triggered.</p>
047     * @return valid
048     */
049    @NotNull
050    @JsonProperty("valid")
051    public Boolean getValid();
052
053    /**
054     * set targets
055     * @param targets values to be set
056     */
057
058    @JsonIgnore
059    public void setTargets(final ItemShippingTarget... targets);
060
061    /**
062     * set targets
063     * @param targets values to be set
064     */
065
066    public void setTargets(final List<ItemShippingTarget> targets);
067
068    /**
069     *  <p>true if the quantity of the (custom) line item is equal to the sum of the sub-quantities in <code>targets</code>, <code>false</code> otherwise. A cart cannot be ordered when the value is <code>false</code>. The error InvalidItemShippingDetails will be triggered.</p>
070     * @param valid value to be set
071     */
072
073    public void setValid(final Boolean valid);
074
075    /**
076     * factory method
077     * @return instance of ItemShippingDetails
078     */
079    public static ItemShippingDetails of() {
080        return new ItemShippingDetailsImpl();
081    }
082
083    /**
084     * factory method to create a shallow copy ItemShippingDetails
085     * @param template instance to be copied
086     * @return copy instance
087     */
088    public static ItemShippingDetails of(final ItemShippingDetails template) {
089        ItemShippingDetailsImpl instance = new ItemShippingDetailsImpl();
090        instance.setTargets(template.getTargets());
091        instance.setValid(template.getValid());
092        return instance;
093    }
094
095    /**
096     * factory method to create a deep copy of ItemShippingDetails
097     * @param template instance to be copied
098     * @return copy instance
099     */
100    @Nullable
101    public static ItemShippingDetails deepCopy(@Nullable final ItemShippingDetails template) {
102        if (template == null) {
103            return null;
104        }
105        ItemShippingDetailsImpl instance = new ItemShippingDetailsImpl();
106        instance.setTargets(Optional.ofNullable(template.getTargets())
107                .map(t -> t.stream()
108                        .map(com.commercetools.history.models.common.ItemShippingTarget::deepCopy)
109                        .collect(Collectors.toList()))
110                .orElse(null));
111        instance.setValid(template.getValid());
112        return instance;
113    }
114
115    /**
116     * builder factory method for ItemShippingDetails
117     * @return builder
118     */
119    public static ItemShippingDetailsBuilder builder() {
120        return ItemShippingDetailsBuilder.of();
121    }
122
123    /**
124     * create builder for ItemShippingDetails instance
125     * @param template instance with prefilled values for the builder
126     * @return builder
127     */
128    public static ItemShippingDetailsBuilder builder(final ItemShippingDetails template) {
129        return ItemShippingDetailsBuilder.of(template);
130    }
131
132    /**
133     * accessor map function
134     * @param <T> mapped type
135     * @param helper function to map the object
136     * @return mapped value
137     */
138    default <T> T withItemShippingDetails(Function<ItemShippingDetails, T> helper) {
139        return helper.apply(this);
140    }
141
142    /**
143     * gives a TypeReference for usage with Jackson DataBind
144     * @return TypeReference
145     */
146    public static com.fasterxml.jackson.core.type.TypeReference<ItemShippingDetails> typeReference() {
147        return new com.fasterxml.jackson.core.type.TypeReference<ItemShippingDetails>() {
148            @Override
149            public String toString() {
150                return "TypeReference<ItemShippingDetails>";
151            }
152        };
153    }
154}