001 002package com.commercetools.api.models.shipping_method; 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.LocalizedString; 014import com.commercetools.api.models.tax_category.TaxCategoryResourceIdentifier; 015import com.commercetools.api.models.type.CustomFieldsDraft; 016import com.fasterxml.jackson.annotation.*; 017import com.fasterxml.jackson.databind.annotation.*; 018 019import io.vrap.rmf.base.client.utils.Generated; 020 021/** 022 * ShippingMethodDraft 023 * 024 * <hr> 025 * Example to create an instance using the builder pattern 026 * <div class=code-example> 027 * <pre><code class='java'> 028 * ShippingMethodDraft shippingMethodDraft = ShippingMethodDraft.builder() 029 * .name("{name}") 030 * .taxCategory(taxCategoryBuilder -> taxCategoryBuilder) 031 * .plusZoneRates(zoneRatesBuilder -> zoneRatesBuilder) 032 * .isDefault(true) 033 * .build() 034 * </code></pre> 035 * </div> 036 */ 037@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen") 038@JsonDeserialize(as = ShippingMethodDraftImpl.class) 039public interface ShippingMethodDraft extends com.commercetools.api.models.CustomizableDraft<ShippingMethodDraft>, 040 com.commercetools.api.models.WithKey, io.vrap.rmf.base.client.Draft<ShippingMethodDraft> { 041 042 /** 043 * <p>User-defined unique identifier for the ShippingMethod.</p> 044 * @return key 045 */ 046 047 @JsonProperty("key") 048 public String getKey(); 049 050 /** 051 * <p>Name of the ShippingMethod.</p> 052 * @return name 053 */ 054 @NotNull 055 @JsonProperty("name") 056 public String getName(); 057 058 /** 059 * <p>Localized name of the ShippingMethod.</p> 060 * @return localizedName 061 */ 062 @Valid 063 @JsonProperty("localizedName") 064 public LocalizedString getLocalizedName(); 065 066 /** 067 * <p>Description of the ShippingMethod.</p> 068 * @return description 069 */ 070 @Deprecated 071 @JsonProperty("description") 072 public String getDescription(); 073 074 /** 075 * <p>Localized description of the ShippingMethod.</p> 076 * @return localizedDescription 077 */ 078 @Valid 079 @JsonProperty("localizedDescription") 080 public LocalizedString getLocalizedDescription(); 081 082 /** 083 * <p>TaxCategory for all ZoneRates of the ShippingMethod.</p> 084 * @return taxCategory 085 */ 086 @NotNull 087 @Valid 088 @JsonProperty("taxCategory") 089 public TaxCategoryResourceIdentifier getTaxCategory(); 090 091 /** 092 * <p>Defines ShippingRates (prices) for specific zones.</p> 093 * @return zoneRates 094 */ 095 @NotNull 096 @Valid 097 @JsonProperty("zoneRates") 098 public List<ZoneRateDraft> getZoneRates(); 099 100 /** 101 * <p>If <code>true</code> the ShippingMethod will be the Project's default ShippingMethod.</p> 102 * @return isDefault 103 */ 104 @NotNull 105 @JsonProperty("isDefault") 106 public Boolean getIsDefault(); 107 108 /** 109 * <p>Valid Cart predicate to select a ShippingMethod for a Cart.</p> 110 * @return predicate 111 */ 112 113 @JsonProperty("predicate") 114 public String getPredicate(); 115 116 /** 117 * <p>Custom Fields for the ShippingMethod.</p> 118 * @return custom 119 */ 120 @Valid 121 @JsonProperty("custom") 122 public CustomFieldsDraft getCustom(); 123 124 /** 125 * <p>User-defined unique identifier for the ShippingMethod.</p> 126 * @param key value to be set 127 */ 128 129 public void setKey(final String key); 130 131 /** 132 * <p>Name of the ShippingMethod.</p> 133 * @param name value to be set 134 */ 135 136 public void setName(final String name); 137 138 /** 139 * <p>Localized name of the ShippingMethod.</p> 140 * @param localizedName value to be set 141 */ 142 143 public void setLocalizedName(final LocalizedString localizedName); 144 145 /** 146 * <p>Description of the ShippingMethod.</p> 147 * @param description value to be set 148 */ 149 @Deprecated 150 public void setDescription(final String description); 151 152 /** 153 * <p>Localized description of the ShippingMethod.</p> 154 * @param localizedDescription value to be set 155 */ 156 157 public void setLocalizedDescription(final LocalizedString localizedDescription); 158 159 /** 160 * <p>TaxCategory for all ZoneRates of the ShippingMethod.</p> 161 * @param taxCategory value to be set 162 */ 163 164 public void setTaxCategory(final TaxCategoryResourceIdentifier taxCategory); 165 166 /** 167 * <p>Defines ShippingRates (prices) for specific zones.</p> 168 * @param zoneRates values to be set 169 */ 170 171 @JsonIgnore 172 public void setZoneRates(final ZoneRateDraft... zoneRates); 173 174 /** 175 * <p>Defines ShippingRates (prices) for specific zones.</p> 176 * @param zoneRates values to be set 177 */ 178 179 public void setZoneRates(final List<ZoneRateDraft> zoneRates); 180 181 /** 182 * <p>If <code>true</code> the ShippingMethod will be the Project's default ShippingMethod.</p> 183 * @param isDefault value to be set 184 */ 185 186 public void setIsDefault(final Boolean isDefault); 187 188 /** 189 * <p>Valid Cart predicate to select a ShippingMethod for a Cart.</p> 190 * @param predicate value to be set 191 */ 192 193 public void setPredicate(final String predicate); 194 195 /** 196 * <p>Custom Fields for the ShippingMethod.</p> 197 * @param custom value to be set 198 */ 199 200 public void setCustom(final CustomFieldsDraft custom); 201 202 /** 203 * factory method 204 * @return instance of ShippingMethodDraft 205 */ 206 public static ShippingMethodDraft of() { 207 return new ShippingMethodDraftImpl(); 208 } 209 210 /** 211 * factory method to create a shallow copy ShippingMethodDraft 212 * @param template instance to be copied 213 * @return copy instance 214 */ 215 public static ShippingMethodDraft of(final ShippingMethodDraft template) { 216 ShippingMethodDraftImpl instance = new ShippingMethodDraftImpl(); 217 instance.setKey(template.getKey()); 218 instance.setName(template.getName()); 219 instance.setLocalizedName(template.getLocalizedName()); 220 instance.setDescription(template.getDescription()); 221 instance.setLocalizedDescription(template.getLocalizedDescription()); 222 instance.setTaxCategory(template.getTaxCategory()); 223 instance.setZoneRates(template.getZoneRates()); 224 instance.setIsDefault(template.getIsDefault()); 225 instance.setPredicate(template.getPredicate()); 226 instance.setCustom(template.getCustom()); 227 return instance; 228 } 229 230 /** 231 * factory method to create a deep copy of ShippingMethodDraft 232 * @param template instance to be copied 233 * @return copy instance 234 */ 235 @Nullable 236 public static ShippingMethodDraft deepCopy(@Nullable final ShippingMethodDraft template) { 237 if (template == null) { 238 return null; 239 } 240 ShippingMethodDraftImpl instance = new ShippingMethodDraftImpl(); 241 instance.setKey(template.getKey()); 242 instance.setName(template.getName()); 243 instance.setLocalizedName( 244 com.commercetools.api.models.common.LocalizedString.deepCopy(template.getLocalizedName())); 245 instance.setDescription(template.getDescription()); 246 instance.setLocalizedDescription( 247 com.commercetools.api.models.common.LocalizedString.deepCopy(template.getLocalizedDescription())); 248 instance.setTaxCategory(com.commercetools.api.models.tax_category.TaxCategoryResourceIdentifier 249 .deepCopy(template.getTaxCategory())); 250 instance.setZoneRates(Optional.ofNullable(template.getZoneRates()) 251 .map(t -> t.stream() 252 .map(com.commercetools.api.models.shipping_method.ZoneRateDraft::deepCopy) 253 .collect(Collectors.toList())) 254 .orElse(null)); 255 instance.setIsDefault(template.getIsDefault()); 256 instance.setPredicate(template.getPredicate()); 257 instance.setCustom(com.commercetools.api.models.type.CustomFieldsDraft.deepCopy(template.getCustom())); 258 return instance; 259 } 260 261 /** 262 * builder factory method for ShippingMethodDraft 263 * @return builder 264 */ 265 public static ShippingMethodDraftBuilder builder() { 266 return ShippingMethodDraftBuilder.of(); 267 } 268 269 /** 270 * create builder for ShippingMethodDraft instance 271 * @param template instance with prefilled values for the builder 272 * @return builder 273 */ 274 public static ShippingMethodDraftBuilder builder(final ShippingMethodDraft template) { 275 return ShippingMethodDraftBuilder.of(template); 276 } 277 278 /** 279 * accessor map function 280 * @param <T> mapped type 281 * @param helper function to map the object 282 * @return mapped value 283 */ 284 default <T> T withShippingMethodDraft(Function<ShippingMethodDraft, T> helper) { 285 return helper.apply(this); 286 } 287 288 /** 289 * gives a TypeReference for usage with Jackson DataBind 290 * @return TypeReference 291 */ 292 public static com.fasterxml.jackson.core.type.TypeReference<ShippingMethodDraft> typeReference() { 293 return new com.fasterxml.jackson.core.type.TypeReference<ShippingMethodDraft>() { 294 @Override 295 public String toString() { 296 return "TypeReference<ShippingMethodDraft>"; 297 } 298 }; 299 } 300}