001 002package com.commercetools.api.models.cart_discount; 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 * CartDiscountValueFixedBuilder 012 * <hr> 013 * Example to create an instance using the builder pattern 014 * <div class=code-example> 015 * <pre><code class='java'> 016 * CartDiscountValueFixed cartDiscountValueFixed = CartDiscountValueFixed.builder() 017 * .plusMoney(moneyBuilder -> moneyBuilder) 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 CartDiscountValueFixedBuilder implements Builder<CartDiscountValueFixed> { 024 025 private java.util.List<com.commercetools.api.models.common.TypedMoney> money; 026 027 /** 028 * <p>Money values in cent precision or high precision of different currencies.</p> 029 * @param money value to be set 030 * @return Builder 031 */ 032 033 public CartDiscountValueFixedBuilder money(final com.commercetools.api.models.common.TypedMoney... money) { 034 this.money = new ArrayList<>(Arrays.asList(money)); 035 return this; 036 } 037 038 /** 039 * <p>Money values in cent precision or high precision of different currencies.</p> 040 * @param money value to be set 041 * @return Builder 042 */ 043 044 public CartDiscountValueFixedBuilder money( 045 final java.util.List<com.commercetools.api.models.common.TypedMoney> money) { 046 this.money = money; 047 return this; 048 } 049 050 /** 051 * <p>Money values in cent precision or high precision of different currencies.</p> 052 * @param money value to be set 053 * @return Builder 054 */ 055 056 public CartDiscountValueFixedBuilder plusMoney(final com.commercetools.api.models.common.TypedMoney... money) { 057 if (this.money == null) { 058 this.money = new ArrayList<>(); 059 } 060 this.money.addAll(Arrays.asList(money)); 061 return this; 062 } 063 064 /** 065 * <p>Money values in cent precision or high precision of different currencies.</p> 066 * @param builder function to build the money value 067 * @return Builder 068 */ 069 070 public CartDiscountValueFixedBuilder plusMoney( 071 Function<com.commercetools.api.models.common.TypedMoneyBuilder, Builder<? extends com.commercetools.api.models.common.TypedMoney>> builder) { 072 if (this.money == null) { 073 this.money = new ArrayList<>(); 074 } 075 this.money.add(builder.apply(com.commercetools.api.models.common.TypedMoneyBuilder.of()).build()); 076 return this; 077 } 078 079 /** 080 * <p>Money values in cent precision or high precision of different currencies.</p> 081 * @param builder function to build the money value 082 * @return Builder 083 */ 084 085 public CartDiscountValueFixedBuilder withMoney( 086 Function<com.commercetools.api.models.common.TypedMoneyBuilder, Builder<? extends com.commercetools.api.models.common.TypedMoney>> builder) { 087 this.money = new ArrayList<>(); 088 this.money.add(builder.apply(com.commercetools.api.models.common.TypedMoneyBuilder.of()).build()); 089 return this; 090 } 091 092 /** 093 * <p>Money values in cent precision or high precision of different currencies.</p> 094 * @return money 095 */ 096 097 public java.util.List<com.commercetools.api.models.common.TypedMoney> getMoney() { 098 return this.money; 099 } 100 101 /** 102 * builds CartDiscountValueFixed with checking for non-null required values 103 * @return CartDiscountValueFixed 104 */ 105 public CartDiscountValueFixed build() { 106 Objects.requireNonNull(money, CartDiscountValueFixed.class + ": money is missing"); 107 return new CartDiscountValueFixedImpl(money); 108 } 109 110 /** 111 * builds CartDiscountValueFixed without checking for non-null required values 112 * @return CartDiscountValueFixed 113 */ 114 public CartDiscountValueFixed buildUnchecked() { 115 return new CartDiscountValueFixedImpl(money); 116 } 117 118 /** 119 * factory method for an instance of CartDiscountValueFixedBuilder 120 * @return builder 121 */ 122 public static CartDiscountValueFixedBuilder of() { 123 return new CartDiscountValueFixedBuilder(); 124 } 125 126 /** 127 * create builder for CartDiscountValueFixed instance 128 * @param template instance with prefilled values for the builder 129 * @return builder 130 */ 131 public static CartDiscountValueFixedBuilder of(final CartDiscountValueFixed template) { 132 CartDiscountValueFixedBuilder builder = new CartDiscountValueFixedBuilder(); 133 builder.money = template.getMoney(); 134 return builder; 135 } 136 137}