001 002package com.commercetools.importapi.models.orders; 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 * LineItemPriceBuilder 014 * <hr> 015 * Example to create an instance using the builder pattern 016 * <div class=code-example> 017 * <pre><code class='java'> 018 * LineItemPrice lineItemPrice = LineItemPrice.builder() 019 * .value(valueBuilder -> valueBuilder) 020 * .build() 021 * </code></pre> 022 * </div> 023 */ 024@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen") 025public class LineItemPriceBuilder implements Builder<LineItemPrice> { 026 027 private com.commercetools.importapi.models.common.TypedMoney value; 028 029 @Nullable 030 private String country; 031 032 @Nullable 033 private java.time.ZonedDateTime validFrom; 034 035 @Nullable 036 private java.time.ZonedDateTime validUntil; 037 038 @Nullable 039 private com.commercetools.importapi.models.common.CustomerGroupKeyReference customerGroup; 040 041 @Nullable 042 private com.commercetools.importapi.models.common.ChannelKeyReference channel; 043 044 @Nullable 045 private com.commercetools.importapi.models.common.DiscountedPrice discounted; 046 047 @Nullable 048 private java.util.List<com.commercetools.importapi.models.common.PriceTier> tiers; 049 050 @Nullable 051 private com.commercetools.importapi.models.customfields.Custom custom; 052 053 /** 054 * <p>Maps to <code>Price.value</code>.</p> 055 * @param value value to be set 056 * @return Builder 057 */ 058 059 public LineItemPriceBuilder value(final com.commercetools.importapi.models.common.TypedMoney value) { 060 this.value = value; 061 return this; 062 } 063 064 /** 065 * <p>Maps to <code>Price.value</code>.</p> 066 * @param builder function to build the value value 067 * @return Builder 068 */ 069 070 public LineItemPriceBuilder value( 071 Function<com.commercetools.importapi.models.common.TypedMoneyBuilder, Builder<? extends com.commercetools.importapi.models.common.TypedMoney>> builder) { 072 this.value = builder.apply(com.commercetools.importapi.models.common.TypedMoneyBuilder.of()).build(); 073 return this; 074 } 075 076 /** 077 * <p>Maps to <code>Price.county</code>.</p> 078 * @param country value to be set 079 * @return Builder 080 */ 081 082 public LineItemPriceBuilder country(@Nullable final String country) { 083 this.country = country; 084 return this; 085 } 086 087 /** 088 * <p>Maps to <code>Price.validFrom</code>.</p> 089 * @param validFrom value to be set 090 * @return Builder 091 */ 092 093 public LineItemPriceBuilder validFrom(@Nullable final java.time.ZonedDateTime validFrom) { 094 this.validFrom = validFrom; 095 return this; 096 } 097 098 /** 099 * <p>Maps to <code>Price.validUntil</code>.</p> 100 * @param validUntil value to be set 101 * @return Builder 102 */ 103 104 public LineItemPriceBuilder validUntil(@Nullable final java.time.ZonedDateTime validUntil) { 105 this.validUntil = validUntil; 106 return this; 107 } 108 109 /** 110 * <p>References a customer group by key.</p> 111 * @param builder function to build the customerGroup value 112 * @return Builder 113 */ 114 115 public LineItemPriceBuilder customerGroup( 116 Function<com.commercetools.importapi.models.common.CustomerGroupKeyReferenceBuilder, com.commercetools.importapi.models.common.CustomerGroupKeyReferenceBuilder> builder) { 117 this.customerGroup = builder 118 .apply(com.commercetools.importapi.models.common.CustomerGroupKeyReferenceBuilder.of()) 119 .build(); 120 return this; 121 } 122 123 /** 124 * <p>References a customer group by key.</p> 125 * @param builder function to build the customerGroup value 126 * @return Builder 127 */ 128 129 public LineItemPriceBuilder withCustomerGroup( 130 Function<com.commercetools.importapi.models.common.CustomerGroupKeyReferenceBuilder, com.commercetools.importapi.models.common.CustomerGroupKeyReference> builder) { 131 this.customerGroup = builder 132 .apply(com.commercetools.importapi.models.common.CustomerGroupKeyReferenceBuilder.of()); 133 return this; 134 } 135 136 /** 137 * <p>References a customer group by key.</p> 138 * @param customerGroup value to be set 139 * @return Builder 140 */ 141 142 public LineItemPriceBuilder customerGroup( 143 @Nullable final com.commercetools.importapi.models.common.CustomerGroupKeyReference customerGroup) { 144 this.customerGroup = customerGroup; 145 return this; 146 } 147 148 /** 149 * <p>References a channel by key.</p> 150 * @param builder function to build the channel value 151 * @return Builder 152 */ 153 154 public LineItemPriceBuilder channel( 155 Function<com.commercetools.importapi.models.common.ChannelKeyReferenceBuilder, com.commercetools.importapi.models.common.ChannelKeyReferenceBuilder> builder) { 156 this.channel = builder.apply(com.commercetools.importapi.models.common.ChannelKeyReferenceBuilder.of()).build(); 157 return this; 158 } 159 160 /** 161 * <p>References a channel by key.</p> 162 * @param builder function to build the channel value 163 * @return Builder 164 */ 165 166 public LineItemPriceBuilder withChannel( 167 Function<com.commercetools.importapi.models.common.ChannelKeyReferenceBuilder, com.commercetools.importapi.models.common.ChannelKeyReference> builder) { 168 this.channel = builder.apply(com.commercetools.importapi.models.common.ChannelKeyReferenceBuilder.of()); 169 return this; 170 } 171 172 /** 173 * <p>References a channel by key.</p> 174 * @param channel value to be set 175 * @return Builder 176 */ 177 178 public LineItemPriceBuilder channel( 179 @Nullable final com.commercetools.importapi.models.common.ChannelKeyReference channel) { 180 this.channel = channel; 181 return this; 182 } 183 184 /** 185 * <p>Sets a discounted price from an external service.</p> 186 * @param builder function to build the discounted value 187 * @return Builder 188 */ 189 190 public LineItemPriceBuilder discounted( 191 Function<com.commercetools.importapi.models.common.DiscountedPriceBuilder, com.commercetools.importapi.models.common.DiscountedPriceBuilder> builder) { 192 this.discounted = builder.apply(com.commercetools.importapi.models.common.DiscountedPriceBuilder.of()).build(); 193 return this; 194 } 195 196 /** 197 * <p>Sets a discounted price from an external service.</p> 198 * @param builder function to build the discounted value 199 * @return Builder 200 */ 201 202 public LineItemPriceBuilder withDiscounted( 203 Function<com.commercetools.importapi.models.common.DiscountedPriceBuilder, com.commercetools.importapi.models.common.DiscountedPrice> builder) { 204 this.discounted = builder.apply(com.commercetools.importapi.models.common.DiscountedPriceBuilder.of()); 205 return this; 206 } 207 208 /** 209 * <p>Sets a discounted price from an external service.</p> 210 * @param discounted value to be set 211 * @return Builder 212 */ 213 214 public LineItemPriceBuilder discounted( 215 @Nullable final com.commercetools.importapi.models.common.DiscountedPrice discounted) { 216 this.discounted = discounted; 217 return this; 218 } 219 220 /** 221 * <p>The tiered prices for this price.</p> 222 * @param tiers value to be set 223 * @return Builder 224 */ 225 226 public LineItemPriceBuilder tiers(@Nullable final com.commercetools.importapi.models.common.PriceTier... tiers) { 227 this.tiers = new ArrayList<>(Arrays.asList(tiers)); 228 return this; 229 } 230 231 /** 232 * <p>The tiered prices for this price.</p> 233 * @param tiers value to be set 234 * @return Builder 235 */ 236 237 public LineItemPriceBuilder tiers( 238 @Nullable final java.util.List<com.commercetools.importapi.models.common.PriceTier> tiers) { 239 this.tiers = tiers; 240 return this; 241 } 242 243 /** 244 * <p>The tiered prices for this price.</p> 245 * @param tiers value to be set 246 * @return Builder 247 */ 248 249 public LineItemPriceBuilder plusTiers( 250 @Nullable final com.commercetools.importapi.models.common.PriceTier... tiers) { 251 if (this.tiers == null) { 252 this.tiers = new ArrayList<>(); 253 } 254 this.tiers.addAll(Arrays.asList(tiers)); 255 return this; 256 } 257 258 /** 259 * <p>The tiered prices for this price.</p> 260 * @param builder function to build the tiers value 261 * @return Builder 262 */ 263 264 public LineItemPriceBuilder plusTiers( 265 Function<com.commercetools.importapi.models.common.PriceTierBuilder, com.commercetools.importapi.models.common.PriceTierBuilder> builder) { 266 if (this.tiers == null) { 267 this.tiers = new ArrayList<>(); 268 } 269 this.tiers.add(builder.apply(com.commercetools.importapi.models.common.PriceTierBuilder.of()).build()); 270 return this; 271 } 272 273 /** 274 * <p>The tiered prices for this price.</p> 275 * @param builder function to build the tiers value 276 * @return Builder 277 */ 278 279 public LineItemPriceBuilder withTiers( 280 Function<com.commercetools.importapi.models.common.PriceTierBuilder, com.commercetools.importapi.models.common.PriceTierBuilder> builder) { 281 this.tiers = new ArrayList<>(); 282 this.tiers.add(builder.apply(com.commercetools.importapi.models.common.PriceTierBuilder.of()).build()); 283 return this; 284 } 285 286 /** 287 * <p>The tiered prices for this price.</p> 288 * @param builder function to build the tiers value 289 * @return Builder 290 */ 291 292 public LineItemPriceBuilder addTiers( 293 Function<com.commercetools.importapi.models.common.PriceTierBuilder, com.commercetools.importapi.models.common.PriceTier> builder) { 294 return plusTiers(builder.apply(com.commercetools.importapi.models.common.PriceTierBuilder.of())); 295 } 296 297 /** 298 * <p>The tiered prices for this price.</p> 299 * @param builder function to build the tiers value 300 * @return Builder 301 */ 302 303 public LineItemPriceBuilder setTiers( 304 Function<com.commercetools.importapi.models.common.PriceTierBuilder, com.commercetools.importapi.models.common.PriceTier> builder) { 305 return tiers(builder.apply(com.commercetools.importapi.models.common.PriceTierBuilder.of())); 306 } 307 308 /** 309 * <p>Maps to <code>Price.custom</code>.</p> 310 * @param builder function to build the custom value 311 * @return Builder 312 */ 313 314 public LineItemPriceBuilder custom( 315 Function<com.commercetools.importapi.models.customfields.CustomBuilder, com.commercetools.importapi.models.customfields.CustomBuilder> builder) { 316 this.custom = builder.apply(com.commercetools.importapi.models.customfields.CustomBuilder.of()).build(); 317 return this; 318 } 319 320 /** 321 * <p>Maps to <code>Price.custom</code>.</p> 322 * @param builder function to build the custom value 323 * @return Builder 324 */ 325 326 public LineItemPriceBuilder withCustom( 327 Function<com.commercetools.importapi.models.customfields.CustomBuilder, com.commercetools.importapi.models.customfields.Custom> builder) { 328 this.custom = builder.apply(com.commercetools.importapi.models.customfields.CustomBuilder.of()); 329 return this; 330 } 331 332 /** 333 * <p>Maps to <code>Price.custom</code>.</p> 334 * @param custom value to be set 335 * @return Builder 336 */ 337 338 public LineItemPriceBuilder custom(@Nullable final com.commercetools.importapi.models.customfields.Custom custom) { 339 this.custom = custom; 340 return this; 341 } 342 343 /** 344 * <p>Maps to <code>Price.value</code>.</p> 345 * @return value 346 */ 347 348 public com.commercetools.importapi.models.common.TypedMoney getValue() { 349 return this.value; 350 } 351 352 /** 353 * <p>Maps to <code>Price.county</code>.</p> 354 * @return country 355 */ 356 357 @Nullable 358 public String getCountry() { 359 return this.country; 360 } 361 362 /** 363 * <p>Maps to <code>Price.validFrom</code>.</p> 364 * @return validFrom 365 */ 366 367 @Nullable 368 public java.time.ZonedDateTime getValidFrom() { 369 return this.validFrom; 370 } 371 372 /** 373 * <p>Maps to <code>Price.validUntil</code>.</p> 374 * @return validUntil 375 */ 376 377 @Nullable 378 public java.time.ZonedDateTime getValidUntil() { 379 return this.validUntil; 380 } 381 382 /** 383 * <p>References a customer group by key.</p> 384 * @return customerGroup 385 */ 386 387 @Nullable 388 public com.commercetools.importapi.models.common.CustomerGroupKeyReference getCustomerGroup() { 389 return this.customerGroup; 390 } 391 392 /** 393 * <p>References a channel by key.</p> 394 * @return channel 395 */ 396 397 @Nullable 398 public com.commercetools.importapi.models.common.ChannelKeyReference getChannel() { 399 return this.channel; 400 } 401 402 /** 403 * <p>Sets a discounted price from an external service.</p> 404 * @return discounted 405 */ 406 407 @Nullable 408 public com.commercetools.importapi.models.common.DiscountedPrice getDiscounted() { 409 return this.discounted; 410 } 411 412 /** 413 * <p>The tiered prices for this price.</p> 414 * @return tiers 415 */ 416 417 @Nullable 418 public java.util.List<com.commercetools.importapi.models.common.PriceTier> getTiers() { 419 return this.tiers; 420 } 421 422 /** 423 * <p>Maps to <code>Price.custom</code>.</p> 424 * @return custom 425 */ 426 427 @Nullable 428 public com.commercetools.importapi.models.customfields.Custom getCustom() { 429 return this.custom; 430 } 431 432 /** 433 * builds LineItemPrice with checking for non-null required values 434 * @return LineItemPrice 435 */ 436 public LineItemPrice build() { 437 Objects.requireNonNull(value, LineItemPrice.class + ": value is missing"); 438 return new LineItemPriceImpl(value, country, validFrom, validUntil, customerGroup, channel, discounted, tiers, 439 custom); 440 } 441 442 /** 443 * builds LineItemPrice without checking for non-null required values 444 * @return LineItemPrice 445 */ 446 public LineItemPrice buildUnchecked() { 447 return new LineItemPriceImpl(value, country, validFrom, validUntil, customerGroup, channel, discounted, tiers, 448 custom); 449 } 450 451 /** 452 * factory method for an instance of LineItemPriceBuilder 453 * @return builder 454 */ 455 public static LineItemPriceBuilder of() { 456 return new LineItemPriceBuilder(); 457 } 458 459 /** 460 * create builder for LineItemPrice instance 461 * @param template instance with prefilled values for the builder 462 * @return builder 463 */ 464 public static LineItemPriceBuilder of(final LineItemPrice template) { 465 LineItemPriceBuilder builder = new LineItemPriceBuilder(); 466 builder.value = template.getValue(); 467 builder.country = template.getCountry(); 468 builder.validFrom = template.getValidFrom(); 469 builder.validUntil = template.getValidUntil(); 470 builder.customerGroup = template.getCustomerGroup(); 471 builder.channel = template.getChannel(); 472 builder.discounted = template.getDiscounted(); 473 builder.tiers = template.getTiers(); 474 builder.custom = template.getCustom(); 475 return builder; 476 } 477 478}