001 002package com.commercetools.history.models.common; 003 004import java.util.*; 005import java.util.function.Function; 006 007import io.vrap.rmf.base.client.Builder; 008import io.vrap.rmf.base.client.utils.Generated; 009 010/** 011 * LineItemBuilder 012 * <hr> 013 * Example to create an instance using the builder pattern 014 * <div class=code-example> 015 * <pre><code class='java'> 016 * LineItem lineItem = LineItem.builder() 017 * .addedAt("{addedAt}") 018 * .custom(customBuilder -> customBuilder) 019 * .id("{id}") 020 * .name(nameBuilder -> nameBuilder) 021 * .productId("{productId}") 022 * .productSlug(productSlugBuilder -> productSlugBuilder) 023 * .productType(productTypeBuilder -> productTypeBuilder) 024 * .quantity(1) 025 * .variant(variantBuilder -> variantBuilder) 026 * .variantId(1) 027 * .build() 028 * </code></pre> 029 * </div> 030 */ 031@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen") 032public class LineItemBuilder implements Builder<LineItem> { 033 034 private String addedAt; 035 036 private com.commercetools.history.models.common.CustomFields custom; 037 038 private String id; 039 040 private com.commercetools.history.models.common.LocalizedString name; 041 042 private String productId; 043 044 private com.commercetools.history.models.common.LocalizedString productSlug; 045 046 private com.commercetools.history.models.common.Reference productType; 047 048 private Integer quantity; 049 050 private com.commercetools.history.models.common.Variant variant; 051 052 private Integer variantId; 053 054 /** 055 * set the value to the addedAt 056 * @param addedAt value to be set 057 * @return Builder 058 */ 059 060 public LineItemBuilder addedAt(final String addedAt) { 061 this.addedAt = addedAt; 062 return this; 063 } 064 065 /** 066 * set the value to the custom using the builder function 067 * @param builder function to build the custom value 068 * @return Builder 069 */ 070 071 public LineItemBuilder custom( 072 Function<com.commercetools.history.models.common.CustomFieldsBuilder, com.commercetools.history.models.common.CustomFieldsBuilder> builder) { 073 this.custom = builder.apply(com.commercetools.history.models.common.CustomFieldsBuilder.of()).build(); 074 return this; 075 } 076 077 /** 078 * set the value to the custom using the builder function 079 * @param builder function to build the custom value 080 * @return Builder 081 */ 082 083 public LineItemBuilder withCustom( 084 Function<com.commercetools.history.models.common.CustomFieldsBuilder, com.commercetools.history.models.common.CustomFields> builder) { 085 this.custom = builder.apply(com.commercetools.history.models.common.CustomFieldsBuilder.of()); 086 return this; 087 } 088 089 /** 090 * set the value to the custom 091 * @param custom value to be set 092 * @return Builder 093 */ 094 095 public LineItemBuilder custom(final com.commercetools.history.models.common.CustomFields custom) { 096 this.custom = custom; 097 return this; 098 } 099 100 /** 101 * set the value to the id 102 * @param id value to be set 103 * @return Builder 104 */ 105 106 public LineItemBuilder id(final String id) { 107 this.id = id; 108 return this; 109 } 110 111 /** 112 * set the value to the name using the builder function 113 * @param builder function to build the name value 114 * @return Builder 115 */ 116 117 public LineItemBuilder name( 118 Function<com.commercetools.history.models.common.LocalizedStringBuilder, com.commercetools.history.models.common.LocalizedStringBuilder> builder) { 119 this.name = builder.apply(com.commercetools.history.models.common.LocalizedStringBuilder.of()).build(); 120 return this; 121 } 122 123 /** 124 * set the value to the name using the builder function 125 * @param builder function to build the name value 126 * @return Builder 127 */ 128 129 public LineItemBuilder withName( 130 Function<com.commercetools.history.models.common.LocalizedStringBuilder, com.commercetools.history.models.common.LocalizedString> builder) { 131 this.name = builder.apply(com.commercetools.history.models.common.LocalizedStringBuilder.of()); 132 return this; 133 } 134 135 /** 136 * set the value to the name 137 * @param name value to be set 138 * @return Builder 139 */ 140 141 public LineItemBuilder name(final com.commercetools.history.models.common.LocalizedString name) { 142 this.name = name; 143 return this; 144 } 145 146 /** 147 * set the value to the productId 148 * @param productId value to be set 149 * @return Builder 150 */ 151 152 public LineItemBuilder productId(final String productId) { 153 this.productId = productId; 154 return this; 155 } 156 157 /** 158 * set the value to the productSlug using the builder function 159 * @param builder function to build the productSlug value 160 * @return Builder 161 */ 162 163 public LineItemBuilder productSlug( 164 Function<com.commercetools.history.models.common.LocalizedStringBuilder, com.commercetools.history.models.common.LocalizedStringBuilder> builder) { 165 this.productSlug = builder.apply(com.commercetools.history.models.common.LocalizedStringBuilder.of()).build(); 166 return this; 167 } 168 169 /** 170 * set the value to the productSlug using the builder function 171 * @param builder function to build the productSlug value 172 * @return Builder 173 */ 174 175 public LineItemBuilder withProductSlug( 176 Function<com.commercetools.history.models.common.LocalizedStringBuilder, com.commercetools.history.models.common.LocalizedString> builder) { 177 this.productSlug = builder.apply(com.commercetools.history.models.common.LocalizedStringBuilder.of()); 178 return this; 179 } 180 181 /** 182 * set the value to the productSlug 183 * @param productSlug value to be set 184 * @return Builder 185 */ 186 187 public LineItemBuilder productSlug(final com.commercetools.history.models.common.LocalizedString productSlug) { 188 this.productSlug = productSlug; 189 return this; 190 } 191 192 /** 193 * set the value to the productType using the builder function 194 * @param builder function to build the productType value 195 * @return Builder 196 */ 197 198 public LineItemBuilder productType( 199 Function<com.commercetools.history.models.common.ReferenceBuilder, com.commercetools.history.models.common.ReferenceBuilder> builder) { 200 this.productType = builder.apply(com.commercetools.history.models.common.ReferenceBuilder.of()).build(); 201 return this; 202 } 203 204 /** 205 * set the value to the productType using the builder function 206 * @param builder function to build the productType value 207 * @return Builder 208 */ 209 210 public LineItemBuilder withProductType( 211 Function<com.commercetools.history.models.common.ReferenceBuilder, com.commercetools.history.models.common.Reference> builder) { 212 this.productType = builder.apply(com.commercetools.history.models.common.ReferenceBuilder.of()); 213 return this; 214 } 215 216 /** 217 * set the value to the productType 218 * @param productType value to be set 219 * @return Builder 220 */ 221 222 public LineItemBuilder productType(final com.commercetools.history.models.common.Reference productType) { 223 this.productType = productType; 224 return this; 225 } 226 227 /** 228 * set the value to the quantity 229 * @param quantity value to be set 230 * @return Builder 231 */ 232 233 public LineItemBuilder quantity(final Integer quantity) { 234 this.quantity = quantity; 235 return this; 236 } 237 238 /** 239 * set the value to the variant using the builder function 240 * @param builder function to build the variant value 241 * @return Builder 242 */ 243 244 public LineItemBuilder variant( 245 Function<com.commercetools.history.models.common.VariantBuilder, com.commercetools.history.models.common.VariantBuilder> builder) { 246 this.variant = builder.apply(com.commercetools.history.models.common.VariantBuilder.of()).build(); 247 return this; 248 } 249 250 /** 251 * set the value to the variant using the builder function 252 * @param builder function to build the variant value 253 * @return Builder 254 */ 255 256 public LineItemBuilder withVariant( 257 Function<com.commercetools.history.models.common.VariantBuilder, com.commercetools.history.models.common.Variant> builder) { 258 this.variant = builder.apply(com.commercetools.history.models.common.VariantBuilder.of()); 259 return this; 260 } 261 262 /** 263 * set the value to the variant 264 * @param variant value to be set 265 * @return Builder 266 */ 267 268 public LineItemBuilder variant(final com.commercetools.history.models.common.Variant variant) { 269 this.variant = variant; 270 return this; 271 } 272 273 /** 274 * set the value to the variantId 275 * @param variantId value to be set 276 * @return Builder 277 */ 278 279 public LineItemBuilder variantId(final Integer variantId) { 280 this.variantId = variantId; 281 return this; 282 } 283 284 /** 285 * value of addedAt} 286 * @return addedAt 287 */ 288 289 public String getAddedAt() { 290 return this.addedAt; 291 } 292 293 /** 294 * value of custom} 295 * @return custom 296 */ 297 298 public com.commercetools.history.models.common.CustomFields getCustom() { 299 return this.custom; 300 } 301 302 /** 303 * value of id} 304 * @return id 305 */ 306 307 public String getId() { 308 return this.id; 309 } 310 311 /** 312 * value of name} 313 * @return name 314 */ 315 316 public com.commercetools.history.models.common.LocalizedString getName() { 317 return this.name; 318 } 319 320 /** 321 * value of productId} 322 * @return productId 323 */ 324 325 public String getProductId() { 326 return this.productId; 327 } 328 329 /** 330 * value of productSlug} 331 * @return productSlug 332 */ 333 334 public com.commercetools.history.models.common.LocalizedString getProductSlug() { 335 return this.productSlug; 336 } 337 338 /** 339 * value of productType} 340 * @return productType 341 */ 342 343 public com.commercetools.history.models.common.Reference getProductType() { 344 return this.productType; 345 } 346 347 /** 348 * value of quantity} 349 * @return quantity 350 */ 351 352 public Integer getQuantity() { 353 return this.quantity; 354 } 355 356 /** 357 * value of variant} 358 * @return variant 359 */ 360 361 public com.commercetools.history.models.common.Variant getVariant() { 362 return this.variant; 363 } 364 365 /** 366 * value of variantId} 367 * @return variantId 368 */ 369 370 public Integer getVariantId() { 371 return this.variantId; 372 } 373 374 /** 375 * builds LineItem with checking for non-null required values 376 * @return LineItem 377 */ 378 public LineItem build() { 379 Objects.requireNonNull(addedAt, LineItem.class + ": addedAt is missing"); 380 Objects.requireNonNull(custom, LineItem.class + ": custom is missing"); 381 Objects.requireNonNull(id, LineItem.class + ": id is missing"); 382 Objects.requireNonNull(name, LineItem.class + ": name is missing"); 383 Objects.requireNonNull(productId, LineItem.class + ": productId is missing"); 384 Objects.requireNonNull(productSlug, LineItem.class + ": productSlug is missing"); 385 Objects.requireNonNull(productType, LineItem.class + ": productType is missing"); 386 Objects.requireNonNull(quantity, LineItem.class + ": quantity is missing"); 387 Objects.requireNonNull(variant, LineItem.class + ": variant is missing"); 388 Objects.requireNonNull(variantId, LineItem.class + ": variantId is missing"); 389 return new LineItemImpl(addedAt, custom, id, name, productId, productSlug, productType, quantity, variant, 390 variantId); 391 } 392 393 /** 394 * builds LineItem without checking for non-null required values 395 * @return LineItem 396 */ 397 public LineItem buildUnchecked() { 398 return new LineItemImpl(addedAt, custom, id, name, productId, productSlug, productType, quantity, variant, 399 variantId); 400 } 401 402 /** 403 * factory method for an instance of LineItemBuilder 404 * @return builder 405 */ 406 public static LineItemBuilder of() { 407 return new LineItemBuilder(); 408 } 409 410 /** 411 * create builder for LineItem instance 412 * @param template instance with prefilled values for the builder 413 * @return builder 414 */ 415 public static LineItemBuilder of(final LineItem template) { 416 LineItemBuilder builder = new LineItemBuilder(); 417 builder.addedAt = template.getAddedAt(); 418 builder.custom = template.getCustom(); 419 builder.id = template.getId(); 420 builder.name = template.getName(); 421 builder.productId = template.getProductId(); 422 builder.productSlug = template.getProductSlug(); 423 builder.productType = template.getProductType(); 424 builder.quantity = template.getQuantity(); 425 builder.variant = template.getVariant(); 426 builder.variantId = template.getVariantId(); 427 return builder; 428 } 429 430}