001 002package com.commercetools.history.models.change; 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 * SetVariantSelectionChangeBuilder 012 * <hr> 013 * Example to create an instance using the builder pattern 014 * <div class=code-example> 015 * <pre><code class='java'> 016 * SetVariantSelectionChange setVariantSelectionChange = SetVariantSelectionChange.builder() 017 * .change("{change}") 018 * .previousValue(previousValueBuilder -> previousValueBuilder) 019 * .nextValue(nextValueBuilder -> nextValueBuilder) 020 * .product(productBuilder -> productBuilder) 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 SetVariantSelectionChangeBuilder implements Builder<SetVariantSelectionChange> { 027 028 private String change; 029 030 private com.commercetools.history.models.common.ProductVariantSelection previousValue; 031 032 private com.commercetools.history.models.common.ProductVariantSelection nextValue; 033 034 private com.commercetools.history.models.common.Reference product; 035 036 /** 037 * set the value to the change 038 * @param change value to be set 039 * @return Builder 040 */ 041 042 public SetVariantSelectionChangeBuilder change(final String change) { 043 this.change = change; 044 return this; 045 } 046 047 /** 048 * <p>Value before the change.</p> 049 * @param builder function to build the previousValue value 050 * @return Builder 051 */ 052 053 public SetVariantSelectionChangeBuilder previousValue( 054 Function<com.commercetools.history.models.common.ProductVariantSelectionBuilder, com.commercetools.history.models.common.ProductVariantSelectionBuilder> builder) { 055 this.previousValue = builder.apply(com.commercetools.history.models.common.ProductVariantSelectionBuilder.of()) 056 .build(); 057 return this; 058 } 059 060 /** 061 * <p>Value before the change.</p> 062 * @param builder function to build the previousValue value 063 * @return Builder 064 */ 065 066 public SetVariantSelectionChangeBuilder withPreviousValue( 067 Function<com.commercetools.history.models.common.ProductVariantSelectionBuilder, com.commercetools.history.models.common.ProductVariantSelection> builder) { 068 this.previousValue = builder.apply(com.commercetools.history.models.common.ProductVariantSelectionBuilder.of()); 069 return this; 070 } 071 072 /** 073 * <p>Value before the change.</p> 074 * @param previousValue value to be set 075 * @return Builder 076 */ 077 078 public SetVariantSelectionChangeBuilder previousValue( 079 final com.commercetools.history.models.common.ProductVariantSelection previousValue) { 080 this.previousValue = previousValue; 081 return this; 082 } 083 084 /** 085 * <p>Value after the change.</p> 086 * @param builder function to build the nextValue value 087 * @return Builder 088 */ 089 090 public SetVariantSelectionChangeBuilder nextValue( 091 Function<com.commercetools.history.models.common.ProductVariantSelectionBuilder, com.commercetools.history.models.common.ProductVariantSelectionBuilder> builder) { 092 this.nextValue = builder.apply(com.commercetools.history.models.common.ProductVariantSelectionBuilder.of()) 093 .build(); 094 return this; 095 } 096 097 /** 098 * <p>Value after the change.</p> 099 * @param builder function to build the nextValue value 100 * @return Builder 101 */ 102 103 public SetVariantSelectionChangeBuilder withNextValue( 104 Function<com.commercetools.history.models.common.ProductVariantSelectionBuilder, com.commercetools.history.models.common.ProductVariantSelection> builder) { 105 this.nextValue = builder.apply(com.commercetools.history.models.common.ProductVariantSelectionBuilder.of()); 106 return this; 107 } 108 109 /** 110 * <p>Value after the change.</p> 111 * @param nextValue value to be set 112 * @return Builder 113 */ 114 115 public SetVariantSelectionChangeBuilder nextValue( 116 final com.commercetools.history.models.common.ProductVariantSelection nextValue) { 117 this.nextValue = nextValue; 118 return this; 119 } 120 121 /** 122 * <p>Reference to the updated Product.</p> 123 * @param builder function to build the product value 124 * @return Builder 125 */ 126 127 public SetVariantSelectionChangeBuilder product( 128 Function<com.commercetools.history.models.common.ReferenceBuilder, com.commercetools.history.models.common.ReferenceBuilder> builder) { 129 this.product = builder.apply(com.commercetools.history.models.common.ReferenceBuilder.of()).build(); 130 return this; 131 } 132 133 /** 134 * <p>Reference to the updated Product.</p> 135 * @param builder function to build the product value 136 * @return Builder 137 */ 138 139 public SetVariantSelectionChangeBuilder withProduct( 140 Function<com.commercetools.history.models.common.ReferenceBuilder, com.commercetools.history.models.common.Reference> builder) { 141 this.product = builder.apply(com.commercetools.history.models.common.ReferenceBuilder.of()); 142 return this; 143 } 144 145 /** 146 * <p>Reference to the updated Product.</p> 147 * @param product value to be set 148 * @return Builder 149 */ 150 151 public SetVariantSelectionChangeBuilder product(final com.commercetools.history.models.common.Reference product) { 152 this.product = product; 153 return this; 154 } 155 156 /** 157 * value of change} 158 * @return change 159 */ 160 161 public String getChange() { 162 return this.change; 163 } 164 165 /** 166 * <p>Value before the change.</p> 167 * @return previousValue 168 */ 169 170 public com.commercetools.history.models.common.ProductVariantSelection getPreviousValue() { 171 return this.previousValue; 172 } 173 174 /** 175 * <p>Value after the change.</p> 176 * @return nextValue 177 */ 178 179 public com.commercetools.history.models.common.ProductVariantSelection getNextValue() { 180 return this.nextValue; 181 } 182 183 /** 184 * <p>Reference to the updated Product.</p> 185 * @return product 186 */ 187 188 public com.commercetools.history.models.common.Reference getProduct() { 189 return this.product; 190 } 191 192 /** 193 * builds SetVariantSelectionChange with checking for non-null required values 194 * @return SetVariantSelectionChange 195 */ 196 public SetVariantSelectionChange build() { 197 Objects.requireNonNull(change, SetVariantSelectionChange.class + ": change is missing"); 198 Objects.requireNonNull(previousValue, SetVariantSelectionChange.class + ": previousValue is missing"); 199 Objects.requireNonNull(nextValue, SetVariantSelectionChange.class + ": nextValue is missing"); 200 Objects.requireNonNull(product, SetVariantSelectionChange.class + ": product is missing"); 201 return new SetVariantSelectionChangeImpl(change, previousValue, nextValue, product); 202 } 203 204 /** 205 * builds SetVariantSelectionChange without checking for non-null required values 206 * @return SetVariantSelectionChange 207 */ 208 public SetVariantSelectionChange buildUnchecked() { 209 return new SetVariantSelectionChangeImpl(change, previousValue, nextValue, product); 210 } 211 212 /** 213 * factory method for an instance of SetVariantSelectionChangeBuilder 214 * @return builder 215 */ 216 public static SetVariantSelectionChangeBuilder of() { 217 return new SetVariantSelectionChangeBuilder(); 218 } 219 220 /** 221 * create builder for SetVariantSelectionChange instance 222 * @param template instance with prefilled values for the builder 223 * @return builder 224 */ 225 public static SetVariantSelectionChangeBuilder of(final SetVariantSelectionChange template) { 226 SetVariantSelectionChangeBuilder builder = new SetVariantSelectionChangeBuilder(); 227 builder.change = template.getChange(); 228 builder.previousValue = template.getPreviousValue(); 229 builder.nextValue = template.getNextValue(); 230 builder.product = template.getProduct(); 231 return builder; 232 } 233 234}