001 002package com.commercetools.history.models.change; 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.history.models.common.DeliveryItem; 014import com.fasterxml.jackson.annotation.*; 015import com.fasterxml.jackson.databind.annotation.*; 016 017import io.vrap.rmf.base.client.utils.Generated; 018 019/** 020 * <p>Change triggered by the following update actions:</p> 021 * <ul> 022 * <li>Set Delivery Items on Orders.</li> 023 * <li>Set Delivery Items on Staged Orders.</li> 024 * </ul> 025 * 026 * <hr> 027 * Example to create an instance using the builder pattern 028 * <div class=code-example> 029 * <pre><code class='java'> 030 * SetDeliveryItemsChange setDeliveryItemsChange = SetDeliveryItemsChange.builder() 031 * .change("{change}") 032 * .plusPreviousValue(previousValueBuilder -> previousValueBuilder) 033 * .plusNextValue(nextValueBuilder -> nextValueBuilder) 034 * .deliveryId("{deliveryId}") 035 * .build() 036 * </code></pre> 037 * </div> 038 */ 039@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen") 040@JsonDeserialize(as = SetDeliveryItemsChangeImpl.class) 041public interface SetDeliveryItemsChange extends Change { 042 043 /** 044 * discriminator value for SetDeliveryItemsChange 045 */ 046 String SET_DELIVERY_ITEMS_CHANGE = "SetDeliveryItemsChange"; 047 048 /** 049 * 050 * @return type 051 */ 052 @NotNull 053 @JsonProperty("type") 054 public String getType(); 055 056 /** 057 * 058 * @return change 059 */ 060 @NotNull 061 @JsonProperty("change") 062 public String getChange(); 063 064 /** 065 * <p>Value before the change.</p> 066 * @return previousValue 067 */ 068 @NotNull 069 @Valid 070 @JsonProperty("previousValue") 071 public List<DeliveryItem> getPreviousValue(); 072 073 /** 074 * <p>Value after the change.</p> 075 * @return nextValue 076 */ 077 @NotNull 078 @Valid 079 @JsonProperty("nextValue") 080 public List<DeliveryItem> getNextValue(); 081 082 /** 083 * <p><code>id</code> of the updated Delivery.</p> 084 * @return deliveryId 085 */ 086 @NotNull 087 @JsonProperty("deliveryId") 088 public String getDeliveryId(); 089 090 /** 091 * set change 092 * @param change value to be set 093 */ 094 095 public void setChange(final String change); 096 097 /** 098 * <p>Value before the change.</p> 099 * @param previousValue values to be set 100 */ 101 102 @JsonIgnore 103 public void setPreviousValue(final DeliveryItem... previousValue); 104 105 /** 106 * <p>Value before the change.</p> 107 * @param previousValue values to be set 108 */ 109 110 public void setPreviousValue(final List<DeliveryItem> previousValue); 111 112 /** 113 * <p>Value after the change.</p> 114 * @param nextValue values to be set 115 */ 116 117 @JsonIgnore 118 public void setNextValue(final DeliveryItem... nextValue); 119 120 /** 121 * <p>Value after the change.</p> 122 * @param nextValue values to be set 123 */ 124 125 public void setNextValue(final List<DeliveryItem> nextValue); 126 127 /** 128 * <p><code>id</code> of the updated Delivery.</p> 129 * @param deliveryId value to be set 130 */ 131 132 public void setDeliveryId(final String deliveryId); 133 134 /** 135 * factory method 136 * @return instance of SetDeliveryItemsChange 137 */ 138 public static SetDeliveryItemsChange of() { 139 return new SetDeliveryItemsChangeImpl(); 140 } 141 142 /** 143 * factory method to create a shallow copy SetDeliveryItemsChange 144 * @param template instance to be copied 145 * @return copy instance 146 */ 147 public static SetDeliveryItemsChange of(final SetDeliveryItemsChange template) { 148 SetDeliveryItemsChangeImpl instance = new SetDeliveryItemsChangeImpl(); 149 instance.setChange(template.getChange()); 150 instance.setPreviousValue(template.getPreviousValue()); 151 instance.setNextValue(template.getNextValue()); 152 instance.setDeliveryId(template.getDeliveryId()); 153 return instance; 154 } 155 156 /** 157 * factory method to create a deep copy of SetDeliveryItemsChange 158 * @param template instance to be copied 159 * @return copy instance 160 */ 161 @Nullable 162 public static SetDeliveryItemsChange deepCopy(@Nullable final SetDeliveryItemsChange template) { 163 if (template == null) { 164 return null; 165 } 166 SetDeliveryItemsChangeImpl instance = new SetDeliveryItemsChangeImpl(); 167 instance.setChange(template.getChange()); 168 instance.setPreviousValue(Optional.ofNullable(template.getPreviousValue()) 169 .map(t -> t.stream() 170 .map(com.commercetools.history.models.common.DeliveryItem::deepCopy) 171 .collect(Collectors.toList())) 172 .orElse(null)); 173 instance.setNextValue(Optional.ofNullable(template.getNextValue()) 174 .map(t -> t.stream() 175 .map(com.commercetools.history.models.common.DeliveryItem::deepCopy) 176 .collect(Collectors.toList())) 177 .orElse(null)); 178 instance.setDeliveryId(template.getDeliveryId()); 179 return instance; 180 } 181 182 /** 183 * builder factory method for SetDeliveryItemsChange 184 * @return builder 185 */ 186 public static SetDeliveryItemsChangeBuilder builder() { 187 return SetDeliveryItemsChangeBuilder.of(); 188 } 189 190 /** 191 * create builder for SetDeliveryItemsChange instance 192 * @param template instance with prefilled values for the builder 193 * @return builder 194 */ 195 public static SetDeliveryItemsChangeBuilder builder(final SetDeliveryItemsChange template) { 196 return SetDeliveryItemsChangeBuilder.of(template); 197 } 198 199 /** 200 * accessor map function 201 * @param <T> mapped type 202 * @param helper function to map the object 203 * @return mapped value 204 */ 205 default <T> T withSetDeliveryItemsChange(Function<SetDeliveryItemsChange, T> helper) { 206 return helper.apply(this); 207 } 208 209 /** 210 * gives a TypeReference for usage with Jackson DataBind 211 * @return TypeReference 212 */ 213 public static com.fasterxml.jackson.core.type.TypeReference<SetDeliveryItemsChange> typeReference() { 214 return new com.fasterxml.jackson.core.type.TypeReference<SetDeliveryItemsChange>() { 215 @Override 216 public String toString() { 217 return "TypeReference<SetDeliveryItemsChange>"; 218 } 219 }; 220 } 221}