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 * SetPricesChangeBuilder 012 * <hr> 013 * Example to create an instance using the builder pattern 014 * <div class=code-example> 015 * <pre><code class='java'> 016 * SetPricesChange setPricesChange = SetPricesChange.builder() 017 * .change("{change}") 018 * .plusPreviousValue(previousValueBuilder -> previousValueBuilder) 019 * .plusNextValue(nextValueBuilder -> nextValueBuilder) 020 * .catalogData("{catalogData}") 021 * .variant("{variant}") 022 * .build() 023 * </code></pre> 024 * </div> 025 */ 026@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen") 027public class SetPricesChangeBuilder implements Builder<SetPricesChange> { 028 029 private String change; 030 031 private java.util.List<com.commercetools.history.models.common.Price> previousValue; 032 033 private java.util.List<com.commercetools.history.models.common.Price> nextValue; 034 035 private String catalogData; 036 037 private String variant; 038 039 /** 040 * set the value to the change 041 * @param change value to be set 042 * @return Builder 043 */ 044 045 public SetPricesChangeBuilder change(final String change) { 046 this.change = change; 047 return this; 048 } 049 050 /** 051 * <p>Value before the change.</p> 052 * @param previousValue value to be set 053 * @return Builder 054 */ 055 056 public SetPricesChangeBuilder previousValue(final com.commercetools.history.models.common.Price... previousValue) { 057 this.previousValue = new ArrayList<>(Arrays.asList(previousValue)); 058 return this; 059 } 060 061 /** 062 * <p>Value before the change.</p> 063 * @param previousValue value to be set 064 * @return Builder 065 */ 066 067 public SetPricesChangeBuilder previousValue( 068 final java.util.List<com.commercetools.history.models.common.Price> previousValue) { 069 this.previousValue = previousValue; 070 return this; 071 } 072 073 /** 074 * <p>Value before the change.</p> 075 * @param previousValue value to be set 076 * @return Builder 077 */ 078 079 public SetPricesChangeBuilder plusPreviousValue( 080 final com.commercetools.history.models.common.Price... previousValue) { 081 if (this.previousValue == null) { 082 this.previousValue = new ArrayList<>(); 083 } 084 this.previousValue.addAll(Arrays.asList(previousValue)); 085 return this; 086 } 087 088 /** 089 * <p>Value before the change.</p> 090 * @param builder function to build the previousValue value 091 * @return Builder 092 */ 093 094 public SetPricesChangeBuilder plusPreviousValue( 095 Function<com.commercetools.history.models.common.PriceBuilder, com.commercetools.history.models.common.PriceBuilder> builder) { 096 if (this.previousValue == null) { 097 this.previousValue = new ArrayList<>(); 098 } 099 this.previousValue.add(builder.apply(com.commercetools.history.models.common.PriceBuilder.of()).build()); 100 return this; 101 } 102 103 /** 104 * <p>Value before the change.</p> 105 * @param builder function to build the previousValue value 106 * @return Builder 107 */ 108 109 public SetPricesChangeBuilder withPreviousValue( 110 Function<com.commercetools.history.models.common.PriceBuilder, com.commercetools.history.models.common.PriceBuilder> builder) { 111 this.previousValue = new ArrayList<>(); 112 this.previousValue.add(builder.apply(com.commercetools.history.models.common.PriceBuilder.of()).build()); 113 return this; 114 } 115 116 /** 117 * <p>Value before the change.</p> 118 * @param builder function to build the previousValue value 119 * @return Builder 120 */ 121 122 public SetPricesChangeBuilder addPreviousValue( 123 Function<com.commercetools.history.models.common.PriceBuilder, com.commercetools.history.models.common.Price> builder) { 124 return plusPreviousValue(builder.apply(com.commercetools.history.models.common.PriceBuilder.of())); 125 } 126 127 /** 128 * <p>Value before the change.</p> 129 * @param builder function to build the previousValue value 130 * @return Builder 131 */ 132 133 public SetPricesChangeBuilder setPreviousValue( 134 Function<com.commercetools.history.models.common.PriceBuilder, com.commercetools.history.models.common.Price> builder) { 135 return previousValue(builder.apply(com.commercetools.history.models.common.PriceBuilder.of())); 136 } 137 138 /** 139 * <p>Value after the change.</p> 140 * @param nextValue value to be set 141 * @return Builder 142 */ 143 144 public SetPricesChangeBuilder nextValue(final com.commercetools.history.models.common.Price... nextValue) { 145 this.nextValue = new ArrayList<>(Arrays.asList(nextValue)); 146 return this; 147 } 148 149 /** 150 * <p>Value after the change.</p> 151 * @param nextValue value to be set 152 * @return Builder 153 */ 154 155 public SetPricesChangeBuilder nextValue( 156 final java.util.List<com.commercetools.history.models.common.Price> nextValue) { 157 this.nextValue = nextValue; 158 return this; 159 } 160 161 /** 162 * <p>Value after the change.</p> 163 * @param nextValue value to be set 164 * @return Builder 165 */ 166 167 public SetPricesChangeBuilder plusNextValue(final com.commercetools.history.models.common.Price... nextValue) { 168 if (this.nextValue == null) { 169 this.nextValue = new ArrayList<>(); 170 } 171 this.nextValue.addAll(Arrays.asList(nextValue)); 172 return this; 173 } 174 175 /** 176 * <p>Value after the change.</p> 177 * @param builder function to build the nextValue value 178 * @return Builder 179 */ 180 181 public SetPricesChangeBuilder plusNextValue( 182 Function<com.commercetools.history.models.common.PriceBuilder, com.commercetools.history.models.common.PriceBuilder> builder) { 183 if (this.nextValue == null) { 184 this.nextValue = new ArrayList<>(); 185 } 186 this.nextValue.add(builder.apply(com.commercetools.history.models.common.PriceBuilder.of()).build()); 187 return this; 188 } 189 190 /** 191 * <p>Value after the change.</p> 192 * @param builder function to build the nextValue value 193 * @return Builder 194 */ 195 196 public SetPricesChangeBuilder withNextValue( 197 Function<com.commercetools.history.models.common.PriceBuilder, com.commercetools.history.models.common.PriceBuilder> builder) { 198 this.nextValue = new ArrayList<>(); 199 this.nextValue.add(builder.apply(com.commercetools.history.models.common.PriceBuilder.of()).build()); 200 return this; 201 } 202 203 /** 204 * <p>Value after the change.</p> 205 * @param builder function to build the nextValue value 206 * @return Builder 207 */ 208 209 public SetPricesChangeBuilder addNextValue( 210 Function<com.commercetools.history.models.common.PriceBuilder, com.commercetools.history.models.common.Price> builder) { 211 return plusNextValue(builder.apply(com.commercetools.history.models.common.PriceBuilder.of())); 212 } 213 214 /** 215 * <p>Value after the change.</p> 216 * @param builder function to build the nextValue value 217 * @return Builder 218 */ 219 220 public SetPricesChangeBuilder setNextValue( 221 Function<com.commercetools.history.models.common.PriceBuilder, com.commercetools.history.models.common.Price> builder) { 222 return nextValue(builder.apply(com.commercetools.history.models.common.PriceBuilder.of())); 223 } 224 225 /** 226 * <ul> 227 * <li><code>staged</code>, if the staged ProductCatalogData was updated.</li> 228 * <li><code>current</code>, if the current ProductCatalogData was updated.</li> 229 * </ul> 230 * @param catalogData value to be set 231 * @return Builder 232 */ 233 234 public SetPricesChangeBuilder catalogData(final String catalogData) { 235 this.catalogData = catalogData; 236 return this; 237 } 238 239 /** 240 * <p><code>sku</code> or <code>key</code> of the ProductVariant.</p> 241 * @param variant value to be set 242 * @return Builder 243 */ 244 245 public SetPricesChangeBuilder variant(final String variant) { 246 this.variant = variant; 247 return this; 248 } 249 250 /** 251 * value of change} 252 * @return change 253 */ 254 255 public String getChange() { 256 return this.change; 257 } 258 259 /** 260 * <p>Value before the change.</p> 261 * @return previousValue 262 */ 263 264 public java.util.List<com.commercetools.history.models.common.Price> getPreviousValue() { 265 return this.previousValue; 266 } 267 268 /** 269 * <p>Value after the change.</p> 270 * @return nextValue 271 */ 272 273 public java.util.List<com.commercetools.history.models.common.Price> getNextValue() { 274 return this.nextValue; 275 } 276 277 /** 278 * <ul> 279 * <li><code>staged</code>, if the staged ProductCatalogData was updated.</li> 280 * <li><code>current</code>, if the current ProductCatalogData was updated.</li> 281 * </ul> 282 * @return catalogData 283 */ 284 285 public String getCatalogData() { 286 return this.catalogData; 287 } 288 289 /** 290 * <p><code>sku</code> or <code>key</code> of the ProductVariant.</p> 291 * @return variant 292 */ 293 294 public String getVariant() { 295 return this.variant; 296 } 297 298 /** 299 * builds SetPricesChange with checking for non-null required values 300 * @return SetPricesChange 301 */ 302 public SetPricesChange build() { 303 Objects.requireNonNull(change, SetPricesChange.class + ": change is missing"); 304 Objects.requireNonNull(previousValue, SetPricesChange.class + ": previousValue is missing"); 305 Objects.requireNonNull(nextValue, SetPricesChange.class + ": nextValue is missing"); 306 Objects.requireNonNull(catalogData, SetPricesChange.class + ": catalogData is missing"); 307 Objects.requireNonNull(variant, SetPricesChange.class + ": variant is missing"); 308 return new SetPricesChangeImpl(change, previousValue, nextValue, catalogData, variant); 309 } 310 311 /** 312 * builds SetPricesChange without checking for non-null required values 313 * @return SetPricesChange 314 */ 315 public SetPricesChange buildUnchecked() { 316 return new SetPricesChangeImpl(change, previousValue, nextValue, catalogData, variant); 317 } 318 319 /** 320 * factory method for an instance of SetPricesChangeBuilder 321 * @return builder 322 */ 323 public static SetPricesChangeBuilder of() { 324 return new SetPricesChangeBuilder(); 325 } 326 327 /** 328 * create builder for SetPricesChange instance 329 * @param template instance with prefilled values for the builder 330 * @return builder 331 */ 332 public static SetPricesChangeBuilder of(final SetPricesChange template) { 333 SetPricesChangeBuilder builder = new SetPricesChangeBuilder(); 334 builder.change = template.getChange(); 335 builder.previousValue = template.getPreviousValue(); 336 builder.nextValue = template.getNextValue(); 337 builder.catalogData = template.getCatalogData(); 338 builder.variant = template.getVariant(); 339 return builder; 340 } 341 342}