001
002package com.commercetools.api.models.order;
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.api.models.type.CustomFields;
015import com.fasterxml.jackson.annotation.*;
016import com.fasterxml.jackson.databind.annotation.*;
017
018import io.vrap.rmf.base.client.utils.Generated;
019
020/**
021 *  <p>Information regarding the appearance, content, and shipment of a Parcel.</p>
022 *
023 * <hr>
024 * Example to create an instance using the builder pattern
025 * <div class=code-example>
026 * <pre><code class='java'>
027 *     Parcel parcel = Parcel.builder()
028 *             .id("{id}")
029 *             .createdAt(ZonedDateTime.parse("2022-01-01T12:00:00.301Z"))
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 = ParcelImpl.class)
036public interface Parcel extends ParcelMixin, com.commercetools.api.models.Customizable<Parcel> {
037
038    /**
039     *  <p>Unique identifier of the Parcel.</p>
040     * @return id
041     */
042    @NotNull
043    @JsonProperty("id")
044    public String getId();
045
046    /**
047     *  <p>User-defined unique identifier of the Parcel.</p>
048     * @return key
049     */
050
051    @JsonProperty("key")
052    public String getKey();
053
054    /**
055     *  <p>Date and time (UTC) the Parcel was created.</p>
056     * @return createdAt
057     */
058    @NotNull
059    @JsonProperty("createdAt")
060    public ZonedDateTime getCreatedAt();
061
062    /**
063     *  <p>Information about the dimensions of the Parcel.</p>
064     * @return measurements
065     */
066    @Valid
067    @JsonProperty("measurements")
068    public ParcelMeasurements getMeasurements();
069
070    /**
071     *  <p>Shipment tracking information of the Parcel.</p>
072     * @return trackingData
073     */
074    @Valid
075    @JsonProperty("trackingData")
076    public TrackingData getTrackingData();
077
078    /**
079     *  <p>Line Items or Custom Line Items delivered in this Parcel.</p>
080     * @return items
081     */
082    @Valid
083    @JsonProperty("items")
084    public List<DeliveryItem> getItems();
085
086    /**
087     *  <p>Custom Fields of the Parcel.</p>
088     * @return custom
089     */
090    @Valid
091    @JsonProperty("custom")
092    public CustomFields getCustom();
093
094    /**
095     *  <p>Unique identifier of the Parcel.</p>
096     * @param id value to be set
097     */
098
099    public void setId(final String id);
100
101    /**
102     *  <p>User-defined unique identifier of the Parcel.</p>
103     * @param key value to be set
104     */
105
106    public void setKey(final String key);
107
108    /**
109     *  <p>Date and time (UTC) the Parcel was created.</p>
110     * @param createdAt value to be set
111     */
112
113    public void setCreatedAt(final ZonedDateTime createdAt);
114
115    /**
116     *  <p>Information about the dimensions of the Parcel.</p>
117     * @param measurements value to be set
118     */
119
120    public void setMeasurements(final ParcelMeasurements measurements);
121
122    /**
123     *  <p>Shipment tracking information of the Parcel.</p>
124     * @param trackingData value to be set
125     */
126
127    public void setTrackingData(final TrackingData trackingData);
128
129    /**
130     *  <p>Line Items or Custom Line Items delivered in this Parcel.</p>
131     * @param items values to be set
132     */
133
134    @JsonIgnore
135    public void setItems(final DeliveryItem... items);
136
137    /**
138     *  <p>Line Items or Custom Line Items delivered in this Parcel.</p>
139     * @param items values to be set
140     */
141
142    public void setItems(final List<DeliveryItem> items);
143
144    /**
145     *  <p>Custom Fields of the Parcel.</p>
146     * @param custom value to be set
147     */
148
149    public void setCustom(final CustomFields custom);
150
151    /**
152     * factory method
153     * @return instance of Parcel
154     */
155    public static Parcel of() {
156        return new ParcelImpl();
157    }
158
159    /**
160     * factory method to create a shallow copy Parcel
161     * @param template instance to be copied
162     * @return copy instance
163     */
164    public static Parcel of(final Parcel template) {
165        ParcelImpl instance = new ParcelImpl();
166        instance.setId(template.getId());
167        instance.setKey(template.getKey());
168        instance.setCreatedAt(template.getCreatedAt());
169        instance.setMeasurements(template.getMeasurements());
170        instance.setTrackingData(template.getTrackingData());
171        instance.setItems(template.getItems());
172        instance.setCustom(template.getCustom());
173        return instance;
174    }
175
176    /**
177     * factory method to create a deep copy of Parcel
178     * @param template instance to be copied
179     * @return copy instance
180     */
181    @Nullable
182    public static Parcel deepCopy(@Nullable final Parcel template) {
183        if (template == null) {
184            return null;
185        }
186        ParcelImpl instance = new ParcelImpl();
187        instance.setId(template.getId());
188        instance.setKey(template.getKey());
189        instance.setCreatedAt(template.getCreatedAt());
190        instance.setMeasurements(
191            com.commercetools.api.models.order.ParcelMeasurements.deepCopy(template.getMeasurements()));
192        instance.setTrackingData(com.commercetools.api.models.order.TrackingData.deepCopy(template.getTrackingData()));
193        instance.setItems(Optional.ofNullable(template.getItems())
194                .map(t -> t.stream()
195                        .map(com.commercetools.api.models.order.DeliveryItem::deepCopy)
196                        .collect(Collectors.toList()))
197                .orElse(null));
198        instance.setCustom(com.commercetools.api.models.type.CustomFields.deepCopy(template.getCustom()));
199        return instance;
200    }
201
202    /**
203     * builder factory method for Parcel
204     * @return builder
205     */
206    public static ParcelBuilder builder() {
207        return ParcelBuilder.of();
208    }
209
210    /**
211     * create builder for Parcel instance
212     * @param template instance with prefilled values for the builder
213     * @return builder
214     */
215    public static ParcelBuilder builder(final Parcel template) {
216        return ParcelBuilder.of(template);
217    }
218
219    /**
220     * accessor map function
221     * @param <T> mapped type
222     * @param helper function to map the object
223     * @return mapped value
224     */
225    default <T> T withParcel(Function<Parcel, T> helper) {
226        return helper.apply(this);
227    }
228
229    /**
230     * gives a TypeReference for usage with Jackson DataBind
231     * @return TypeReference
232     */
233    public static com.fasterxml.jackson.core.type.TypeReference<Parcel> typeReference() {
234        return new com.fasterxml.jackson.core.type.TypeReference<Parcel>() {
235            @Override
236            public String toString() {
237                return "TypeReference<Parcel>";
238            }
239        };
240    }
241}