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.customfields.Custom; 015import com.fasterxml.jackson.annotation.*; 016import com.fasterxml.jackson.databind.annotation.*; 017 018import io.vrap.rmf.base.client.utils.Generated; 019 020/** 021 * Parcel 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 { 037 038 /** 039 * 040 * @return id 041 */ 042 @NotNull 043 @JsonProperty("id") 044 public String getId(); 045 046 /** 047 * 048 * @return createdAt 049 */ 050 @NotNull 051 @JsonProperty("createdAt") 052 public ZonedDateTime getCreatedAt(); 053 054 /** 055 * 056 * @return measurements 057 */ 058 @Valid 059 @JsonProperty("measurements") 060 public ParcelMeasurements getMeasurements(); 061 062 /** 063 * 064 * @return trackingData 065 */ 066 @Valid 067 @JsonProperty("trackingData") 068 public TrackingData getTrackingData(); 069 070 /** 071 * 072 * @return items 073 */ 074 @Valid 075 @JsonProperty("items") 076 public List<DeliveryItem> getItems(); 077 078 /** 079 * <p>The representation to be sent to the server when creating a resource with custom fields.</p> 080 * @return custom 081 */ 082 @Valid 083 @JsonProperty("custom") 084 public Custom getCustom(); 085 086 /** 087 * set id 088 * @param id value to be set 089 */ 090 091 public void setId(final String id); 092 093 /** 094 * set createdAt 095 * @param createdAt value to be set 096 */ 097 098 public void setCreatedAt(final ZonedDateTime createdAt); 099 100 /** 101 * set measurements 102 * @param measurements value to be set 103 */ 104 105 public void setMeasurements(final ParcelMeasurements measurements); 106 107 /** 108 * set trackingData 109 * @param trackingData value to be set 110 */ 111 112 public void setTrackingData(final TrackingData trackingData); 113 114 /** 115 * set items 116 * @param items values to be set 117 */ 118 119 @JsonIgnore 120 public void setItems(final DeliveryItem... items); 121 122 /** 123 * set items 124 * @param items values to be set 125 */ 126 127 public void setItems(final List<DeliveryItem> items); 128 129 /** 130 * <p>The representation to be sent to the server when creating a resource with custom fields.</p> 131 * @param custom value to be set 132 */ 133 134 public void setCustom(final Custom custom); 135 136 /** 137 * factory method 138 * @return instance of Parcel 139 */ 140 public static Parcel of() { 141 return new ParcelImpl(); 142 } 143 144 /** 145 * factory method to create a shallow copy Parcel 146 * @param template instance to be copied 147 * @return copy instance 148 */ 149 public static Parcel of(final Parcel template) { 150 ParcelImpl instance = new ParcelImpl(); 151 instance.setId(template.getId()); 152 instance.setCreatedAt(template.getCreatedAt()); 153 instance.setMeasurements(template.getMeasurements()); 154 instance.setTrackingData(template.getTrackingData()); 155 instance.setItems(template.getItems()); 156 instance.setCustom(template.getCustom()); 157 return instance; 158 } 159 160 /** 161 * factory method to create a deep copy of Parcel 162 * @param template instance to be copied 163 * @return copy instance 164 */ 165 @Nullable 166 public static Parcel deepCopy(@Nullable final Parcel template) { 167 if (template == null) { 168 return null; 169 } 170 ParcelImpl instance = new ParcelImpl(); 171 instance.setId(template.getId()); 172 instance.setCreatedAt(template.getCreatedAt()); 173 instance.setMeasurements( 174 com.commercetools.importapi.models.orders.ParcelMeasurements.deepCopy(template.getMeasurements())); 175 instance.setTrackingData( 176 com.commercetools.importapi.models.orders.TrackingData.deepCopy(template.getTrackingData())); 177 instance.setItems(Optional.ofNullable(template.getItems()) 178 .map(t -> t.stream() 179 .map(com.commercetools.importapi.models.orders.DeliveryItem::deepCopy) 180 .collect(Collectors.toList())) 181 .orElse(null)); 182 instance.setCustom(com.commercetools.importapi.models.customfields.Custom.deepCopy(template.getCustom())); 183 return instance; 184 } 185 186 /** 187 * builder factory method for Parcel 188 * @return builder 189 */ 190 public static ParcelBuilder builder() { 191 return ParcelBuilder.of(); 192 } 193 194 /** 195 * create builder for Parcel instance 196 * @param template instance with prefilled values for the builder 197 * @return builder 198 */ 199 public static ParcelBuilder builder(final Parcel template) { 200 return ParcelBuilder.of(template); 201 } 202 203 /** 204 * accessor map function 205 * @param <T> mapped type 206 * @param helper function to map the object 207 * @return mapped value 208 */ 209 default <T> T withParcel(Function<Parcel, T> helper) { 210 return helper.apply(this); 211 } 212 213 /** 214 * gives a TypeReference for usage with Jackson DataBind 215 * @return TypeReference 216 */ 217 public static com.fasterxml.jackson.core.type.TypeReference<Parcel> typeReference() { 218 return new com.fasterxml.jackson.core.type.TypeReference<Parcel>() { 219 @Override 220 public String toString() { 221 return "TypeReference<Parcel>"; 222 } 223 }; 224 } 225}