001 002package com.commercetools.api.models.cart; 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 * TaxedItemPriceBuilder 014 * <hr> 015 * Example to create an instance using the builder pattern 016 * <div class=code-example> 017 * <pre><code class='java'> 018 * TaxedItemPrice taxedItemPrice = TaxedItemPrice.builder() 019 * .totalNet(totalNetBuilder -> totalNetBuilder) 020 * .totalGross(totalGrossBuilder -> totalGrossBuilder) 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 TaxedItemPriceBuilder implements Builder<TaxedItemPrice> { 027 028 private com.commercetools.api.models.common.CentPrecisionMoney totalNet; 029 030 private com.commercetools.api.models.common.CentPrecisionMoney totalGross; 031 032 @Nullable 033 private com.commercetools.api.models.common.CentPrecisionMoney totalTax; 034 035 /** 036 * <p>Total net amount of the Line Item or Custom Line Item.</p> 037 * @param builder function to build the totalNet value 038 * @return Builder 039 */ 040 041 public TaxedItemPriceBuilder totalNet( 042 Function<com.commercetools.api.models.common.CentPrecisionMoneyBuilder, com.commercetools.api.models.common.CentPrecisionMoneyBuilder> builder) { 043 this.totalNet = builder.apply(com.commercetools.api.models.common.CentPrecisionMoneyBuilder.of()).build(); 044 return this; 045 } 046 047 /** 048 * <p>Total net amount of the Line Item or Custom Line Item.</p> 049 * @param builder function to build the totalNet value 050 * @return Builder 051 */ 052 053 public TaxedItemPriceBuilder withTotalNet( 054 Function<com.commercetools.api.models.common.CentPrecisionMoneyBuilder, com.commercetools.api.models.common.CentPrecisionMoney> builder) { 055 this.totalNet = builder.apply(com.commercetools.api.models.common.CentPrecisionMoneyBuilder.of()); 056 return this; 057 } 058 059 /** 060 * <p>Total net amount of the Line Item or Custom Line Item.</p> 061 * @param totalNet value to be set 062 * @return Builder 063 */ 064 065 public TaxedItemPriceBuilder totalNet(final com.commercetools.api.models.common.CentPrecisionMoney totalNet) { 066 this.totalNet = totalNet; 067 return this; 068 } 069 070 /** 071 * <p>Total gross amount of the Line Item or Custom Line Item.</p> 072 * @param builder function to build the totalGross value 073 * @return Builder 074 */ 075 076 public TaxedItemPriceBuilder totalGross( 077 Function<com.commercetools.api.models.common.CentPrecisionMoneyBuilder, com.commercetools.api.models.common.CentPrecisionMoneyBuilder> builder) { 078 this.totalGross = builder.apply(com.commercetools.api.models.common.CentPrecisionMoneyBuilder.of()).build(); 079 return this; 080 } 081 082 /** 083 * <p>Total gross amount of the Line Item or Custom Line Item.</p> 084 * @param builder function to build the totalGross value 085 * @return Builder 086 */ 087 088 public TaxedItemPriceBuilder withTotalGross( 089 Function<com.commercetools.api.models.common.CentPrecisionMoneyBuilder, com.commercetools.api.models.common.CentPrecisionMoney> builder) { 090 this.totalGross = builder.apply(com.commercetools.api.models.common.CentPrecisionMoneyBuilder.of()); 091 return this; 092 } 093 094 /** 095 * <p>Total gross amount of the Line Item or Custom Line Item.</p> 096 * @param totalGross value to be set 097 * @return Builder 098 */ 099 100 public TaxedItemPriceBuilder totalGross(final com.commercetools.api.models.common.CentPrecisionMoney totalGross) { 101 this.totalGross = totalGross; 102 return this; 103 } 104 105 /** 106 * <p>Total tax applicable for the Line Item or Custom Line Item. Automatically calculated as the difference between the <code>totalGross</code> and <code>totalNet</code> values.</p> 107 * @param builder function to build the totalTax value 108 * @return Builder 109 */ 110 111 public TaxedItemPriceBuilder totalTax( 112 Function<com.commercetools.api.models.common.CentPrecisionMoneyBuilder, com.commercetools.api.models.common.CentPrecisionMoneyBuilder> builder) { 113 this.totalTax = builder.apply(com.commercetools.api.models.common.CentPrecisionMoneyBuilder.of()).build(); 114 return this; 115 } 116 117 /** 118 * <p>Total tax applicable for the Line Item or Custom Line Item. Automatically calculated as the difference between the <code>totalGross</code> and <code>totalNet</code> values.</p> 119 * @param builder function to build the totalTax value 120 * @return Builder 121 */ 122 123 public TaxedItemPriceBuilder withTotalTax( 124 Function<com.commercetools.api.models.common.CentPrecisionMoneyBuilder, com.commercetools.api.models.common.CentPrecisionMoney> builder) { 125 this.totalTax = builder.apply(com.commercetools.api.models.common.CentPrecisionMoneyBuilder.of()); 126 return this; 127 } 128 129 /** 130 * <p>Total tax applicable for the Line Item or Custom Line Item. Automatically calculated as the difference between the <code>totalGross</code> and <code>totalNet</code> values.</p> 131 * @param totalTax value to be set 132 * @return Builder 133 */ 134 135 public TaxedItemPriceBuilder totalTax( 136 @Nullable final com.commercetools.api.models.common.CentPrecisionMoney totalTax) { 137 this.totalTax = totalTax; 138 return this; 139 } 140 141 /** 142 * <p>Total net amount of the Line Item or Custom Line Item.</p> 143 * @return totalNet 144 */ 145 146 public com.commercetools.api.models.common.CentPrecisionMoney getTotalNet() { 147 return this.totalNet; 148 } 149 150 /** 151 * <p>Total gross amount of the Line Item or Custom Line Item.</p> 152 * @return totalGross 153 */ 154 155 public com.commercetools.api.models.common.CentPrecisionMoney getTotalGross() { 156 return this.totalGross; 157 } 158 159 /** 160 * <p>Total tax applicable for the Line Item or Custom Line Item. Automatically calculated as the difference between the <code>totalGross</code> and <code>totalNet</code> values.</p> 161 * @return totalTax 162 */ 163 164 @Nullable 165 public com.commercetools.api.models.common.CentPrecisionMoney getTotalTax() { 166 return this.totalTax; 167 } 168 169 /** 170 * builds TaxedItemPrice with checking for non-null required values 171 * @return TaxedItemPrice 172 */ 173 public TaxedItemPrice build() { 174 Objects.requireNonNull(totalNet, TaxedItemPrice.class + ": totalNet is missing"); 175 Objects.requireNonNull(totalGross, TaxedItemPrice.class + ": totalGross is missing"); 176 return new TaxedItemPriceImpl(totalNet, totalGross, totalTax); 177 } 178 179 /** 180 * builds TaxedItemPrice without checking for non-null required values 181 * @return TaxedItemPrice 182 */ 183 public TaxedItemPrice buildUnchecked() { 184 return new TaxedItemPriceImpl(totalNet, totalGross, totalTax); 185 } 186 187 /** 188 * factory method for an instance of TaxedItemPriceBuilder 189 * @return builder 190 */ 191 public static TaxedItemPriceBuilder of() { 192 return new TaxedItemPriceBuilder(); 193 } 194 195 /** 196 * create builder for TaxedItemPrice instance 197 * @param template instance with prefilled values for the builder 198 * @return builder 199 */ 200 public static TaxedItemPriceBuilder of(final TaxedItemPrice template) { 201 TaxedItemPriceBuilder builder = new TaxedItemPriceBuilder(); 202 builder.totalNet = template.getTotalNet(); 203 builder.totalGross = template.getTotalGross(); 204 builder.totalTax = template.getTotalTax(); 205 return builder; 206 } 207 208}