001 002package com.commercetools.history.models.common; 003 004import java.util.*; 005 006import io.vrap.rmf.base.client.Builder; 007import io.vrap.rmf.base.client.utils.Generated; 008 009/** 010 * ProductVariantSelectionBuilder 011 * <hr> 012 * Example to create an instance using the builder pattern 013 * <div class=code-example> 014 * <pre><code class='java'> 015 * ProductVariantSelection productVariantSelection = ProductVariantSelection.builder() 016 * .type(ProductVariantSelectionTypeEnum.INCLUSION) 017 * .plusSkus(skusBuilder -> skusBuilder) 018 * .build() 019 * </code></pre> 020 * </div> 021 */ 022@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen") 023public class ProductVariantSelectionBuilder implements Builder<ProductVariantSelection> { 024 025 private com.commercetools.history.models.common.ProductVariantSelectionTypeEnum type; 026 027 private java.util.List<String> skus; 028 029 /** 030 * set the value to the type 031 * @param type value to be set 032 * @return Builder 033 */ 034 035 public ProductVariantSelectionBuilder type( 036 final com.commercetools.history.models.common.ProductVariantSelectionTypeEnum type) { 037 this.type = type; 038 return this; 039 } 040 041 /** 042 * set values to the skus 043 * @param skus value to be set 044 * @return Builder 045 */ 046 047 public ProductVariantSelectionBuilder skus(final String... skus) { 048 this.skus = new ArrayList<>(Arrays.asList(skus)); 049 return this; 050 } 051 052 /** 053 * set value to the skus 054 * @param skus value to be set 055 * @return Builder 056 */ 057 058 public ProductVariantSelectionBuilder skus(final java.util.List<String> skus) { 059 this.skus = skus; 060 return this; 061 } 062 063 /** 064 * add values to the skus 065 * @param skus value to be set 066 * @return Builder 067 */ 068 069 public ProductVariantSelectionBuilder plusSkus(final String... skus) { 070 if (this.skus == null) { 071 this.skus = new ArrayList<>(); 072 } 073 this.skus.addAll(Arrays.asList(skus)); 074 return this; 075 } 076 077 /** 078 * value of type} 079 * @return type 080 */ 081 082 public com.commercetools.history.models.common.ProductVariantSelectionTypeEnum getType() { 083 return this.type; 084 } 085 086 /** 087 * value of skus} 088 * @return skus 089 */ 090 091 public java.util.List<String> getSkus() { 092 return this.skus; 093 } 094 095 /** 096 * builds ProductVariantSelection with checking for non-null required values 097 * @return ProductVariantSelection 098 */ 099 public ProductVariantSelection build() { 100 Objects.requireNonNull(type, ProductVariantSelection.class + ": type is missing"); 101 Objects.requireNonNull(skus, ProductVariantSelection.class + ": skus is missing"); 102 return new ProductVariantSelectionImpl(type, skus); 103 } 104 105 /** 106 * builds ProductVariantSelection without checking for non-null required values 107 * @return ProductVariantSelection 108 */ 109 public ProductVariantSelection buildUnchecked() { 110 return new ProductVariantSelectionImpl(type, skus); 111 } 112 113 /** 114 * factory method for an instance of ProductVariantSelectionBuilder 115 * @return builder 116 */ 117 public static ProductVariantSelectionBuilder of() { 118 return new ProductVariantSelectionBuilder(); 119 } 120 121 /** 122 * create builder for ProductVariantSelection instance 123 * @param template instance with prefilled values for the builder 124 * @return builder 125 */ 126 public static ProductVariantSelectionBuilder of(final ProductVariantSelection template) { 127 ProductVariantSelectionBuilder builder = new ProductVariantSelectionBuilder(); 128 builder.type = template.getType(); 129 builder.skus = template.getSkus(); 130 return builder; 131 } 132 133}