001 002package com.commercetools.api.models.inventory; 003 004import java.util.*; 005import java.util.function.Function; 006 007import javax.annotation.Nullable; 008 009import io.vrap.rmf.base.client.Builder; 010import io.vrap.rmf.base.client.utils.Generated; 011 012/** 013 * InventoryEntryDraftBuilder 014 * <hr> 015 * Example to create an instance using the builder pattern 016 * <div class=code-example> 017 * <pre><code class='java'> 018 * InventoryEntryDraft inventoryEntryDraft = InventoryEntryDraft.builder() 019 * .sku("{sku}") 020 * .quantityOnStock(0.3) 021 * .build() 022 * </code></pre> 023 * </div> 024 */ 025@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen") 026public class InventoryEntryDraftBuilder implements Builder<InventoryEntryDraft> { 027 028 private String sku; 029 030 @Nullable 031 private String key; 032 033 @Nullable 034 private com.commercetools.api.models.channel.ChannelResourceIdentifier supplyChannel; 035 036 private Long quantityOnStock; 037 038 @Nullable 039 private Long restockableInDays; 040 041 @Nullable 042 private java.time.ZonedDateTime expectedDelivery; 043 044 @Nullable 045 private com.commercetools.api.models.type.CustomFieldsDraft custom; 046 047 /** 048 * <p>ProductVariant <code>sku</code> of the InventoryEntry.</p> 049 * @param sku value to be set 050 * @return Builder 051 */ 052 053 public InventoryEntryDraftBuilder sku(final String sku) { 054 this.sku = sku; 055 return this; 056 } 057 058 /** 059 * <p>User-defined unique identifier for the InventoryEntry.</p> 060 * @param key value to be set 061 * @return Builder 062 */ 063 064 public InventoryEntryDraftBuilder key(@Nullable final String key) { 065 this.key = key; 066 return this; 067 } 068 069 /** 070 * <p>Channel that supplies this InventoryEntry.</p> 071 * @param builder function to build the supplyChannel value 072 * @return Builder 073 */ 074 075 public InventoryEntryDraftBuilder supplyChannel( 076 Function<com.commercetools.api.models.channel.ChannelResourceIdentifierBuilder, com.commercetools.api.models.channel.ChannelResourceIdentifierBuilder> builder) { 077 this.supplyChannel = builder.apply(com.commercetools.api.models.channel.ChannelResourceIdentifierBuilder.of()) 078 .build(); 079 return this; 080 } 081 082 /** 083 * <p>Channel that supplies this InventoryEntry.</p> 084 * @param builder function to build the supplyChannel value 085 * @return Builder 086 */ 087 088 public InventoryEntryDraftBuilder withSupplyChannel( 089 Function<com.commercetools.api.models.channel.ChannelResourceIdentifierBuilder, com.commercetools.api.models.channel.ChannelResourceIdentifier> builder) { 090 this.supplyChannel = builder.apply(com.commercetools.api.models.channel.ChannelResourceIdentifierBuilder.of()); 091 return this; 092 } 093 094 /** 095 * <p>Channel that supplies this InventoryEntry.</p> 096 * @param supplyChannel value to be set 097 * @return Builder 098 */ 099 100 public InventoryEntryDraftBuilder supplyChannel( 101 @Nullable final com.commercetools.api.models.channel.ChannelResourceIdentifier supplyChannel) { 102 this.supplyChannel = supplyChannel; 103 return this; 104 } 105 106 /** 107 * <p>Overall amount of stock.</p> 108 * @param quantityOnStock value to be set 109 * @return Builder 110 */ 111 112 public InventoryEntryDraftBuilder quantityOnStock(final Long quantityOnStock) { 113 this.quantityOnStock = quantityOnStock; 114 return this; 115 } 116 117 /** 118 * <p>How often the InventoryEntry is restocked (in days).</p> 119 * @param restockableInDays value to be set 120 * @return Builder 121 */ 122 123 public InventoryEntryDraftBuilder restockableInDays(@Nullable final Long restockableInDays) { 124 this.restockableInDays = restockableInDays; 125 return this; 126 } 127 128 /** 129 * <p>Date and time of the next restock.</p> 130 * @param expectedDelivery value to be set 131 * @return Builder 132 */ 133 134 public InventoryEntryDraftBuilder expectedDelivery(@Nullable final java.time.ZonedDateTime expectedDelivery) { 135 this.expectedDelivery = expectedDelivery; 136 return this; 137 } 138 139 /** 140 * <p>Custom Fields of the InventoryEntry.</p> 141 * @param builder function to build the custom value 142 * @return Builder 143 */ 144 145 public InventoryEntryDraftBuilder custom( 146 Function<com.commercetools.api.models.type.CustomFieldsDraftBuilder, com.commercetools.api.models.type.CustomFieldsDraftBuilder> builder) { 147 this.custom = builder.apply(com.commercetools.api.models.type.CustomFieldsDraftBuilder.of()).build(); 148 return this; 149 } 150 151 /** 152 * <p>Custom Fields of the InventoryEntry.</p> 153 * @param builder function to build the custom value 154 * @return Builder 155 */ 156 157 public InventoryEntryDraftBuilder withCustom( 158 Function<com.commercetools.api.models.type.CustomFieldsDraftBuilder, com.commercetools.api.models.type.CustomFieldsDraft> builder) { 159 this.custom = builder.apply(com.commercetools.api.models.type.CustomFieldsDraftBuilder.of()); 160 return this; 161 } 162 163 /** 164 * <p>Custom Fields of the InventoryEntry.</p> 165 * @param custom value to be set 166 * @return Builder 167 */ 168 169 public InventoryEntryDraftBuilder custom( 170 @Nullable final com.commercetools.api.models.type.CustomFieldsDraft custom) { 171 this.custom = custom; 172 return this; 173 } 174 175 /** 176 * <p>ProductVariant <code>sku</code> of the InventoryEntry.</p> 177 * @return sku 178 */ 179 180 public String getSku() { 181 return this.sku; 182 } 183 184 /** 185 * <p>User-defined unique identifier for the InventoryEntry.</p> 186 * @return key 187 */ 188 189 @Nullable 190 public String getKey() { 191 return this.key; 192 } 193 194 /** 195 * <p>Channel that supplies this InventoryEntry.</p> 196 * @return supplyChannel 197 */ 198 199 @Nullable 200 public com.commercetools.api.models.channel.ChannelResourceIdentifier getSupplyChannel() { 201 return this.supplyChannel; 202 } 203 204 /** 205 * <p>Overall amount of stock.</p> 206 * @return quantityOnStock 207 */ 208 209 public Long getQuantityOnStock() { 210 return this.quantityOnStock; 211 } 212 213 /** 214 * <p>How often the InventoryEntry is restocked (in days).</p> 215 * @return restockableInDays 216 */ 217 218 @Nullable 219 public Long getRestockableInDays() { 220 return this.restockableInDays; 221 } 222 223 /** 224 * <p>Date and time of the next restock.</p> 225 * @return expectedDelivery 226 */ 227 228 @Nullable 229 public java.time.ZonedDateTime getExpectedDelivery() { 230 return this.expectedDelivery; 231 } 232 233 /** 234 * <p>Custom Fields of the InventoryEntry.</p> 235 * @return custom 236 */ 237 238 @Nullable 239 public com.commercetools.api.models.type.CustomFieldsDraft getCustom() { 240 return this.custom; 241 } 242 243 /** 244 * builds InventoryEntryDraft with checking for non-null required values 245 * @return InventoryEntryDraft 246 */ 247 public InventoryEntryDraft build() { 248 Objects.requireNonNull(sku, InventoryEntryDraft.class + ": sku is missing"); 249 Objects.requireNonNull(quantityOnStock, InventoryEntryDraft.class + ": quantityOnStock is missing"); 250 return new InventoryEntryDraftImpl(sku, key, supplyChannel, quantityOnStock, restockableInDays, 251 expectedDelivery, custom); 252 } 253 254 /** 255 * builds InventoryEntryDraft without checking for non-null required values 256 * @return InventoryEntryDraft 257 */ 258 public InventoryEntryDraft buildUnchecked() { 259 return new InventoryEntryDraftImpl(sku, key, supplyChannel, quantityOnStock, restockableInDays, 260 expectedDelivery, custom); 261 } 262 263 /** 264 * factory method for an instance of InventoryEntryDraftBuilder 265 * @return builder 266 */ 267 public static InventoryEntryDraftBuilder of() { 268 return new InventoryEntryDraftBuilder(); 269 } 270 271 /** 272 * create builder for InventoryEntryDraft instance 273 * @param template instance with prefilled values for the builder 274 * @return builder 275 */ 276 public static InventoryEntryDraftBuilder of(final InventoryEntryDraft template) { 277 InventoryEntryDraftBuilder builder = new InventoryEntryDraftBuilder(); 278 builder.sku = template.getSku(); 279 builder.key = template.getKey(); 280 builder.supplyChannel = template.getSupplyChannel(); 281 builder.quantityOnStock = template.getQuantityOnStock(); 282 builder.restockableInDays = template.getRestockableInDays(); 283 builder.expectedDelivery = template.getExpectedDelivery(); 284 builder.custom = template.getCustom(); 285 return builder; 286 } 287 288}