001 002package com.commercetools.history.models.common; 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 * CustomLineItemBuilder 012 * <hr> 013 * Example to create an instance using the builder pattern 014 * <div class=code-example> 015 * <pre><code class='java'> 016 * CustomLineItem customLineItem = CustomLineItem.builder() 017 * .id("{id}") 018 * .name(nameBuilder -> nameBuilder) 019 * .money(moneyBuilder -> moneyBuilder) 020 * .taxedPrice(taxedPriceBuilder -> taxedPriceBuilder) 021 * .totalPrice(totalPriceBuilder -> totalPriceBuilder) 022 * .slug("{slug}") 023 * .quantity(1) 024 * .build() 025 * </code></pre> 026 * </div> 027 */ 028@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen") 029public class CustomLineItemBuilder implements Builder<CustomLineItem> { 030 031 private String id; 032 033 private com.commercetools.history.models.common.LocalizedString name; 034 035 private com.commercetools.history.models.common.Money money; 036 037 private com.commercetools.history.models.common.TaxedItemPrice taxedPrice; 038 039 private com.commercetools.history.models.common.Money totalPrice; 040 041 private String slug; 042 043 private Integer quantity; 044 045 /** 046 * <p>The unique ID of this CustomLineItem.</p> 047 * @param id value to be set 048 * @return Builder 049 */ 050 051 public CustomLineItemBuilder id(final String id) { 052 this.id = id; 053 return this; 054 } 055 056 /** 057 * set the value to the name using the builder function 058 * @param builder function to build the name value 059 * @return Builder 060 */ 061 062 public CustomLineItemBuilder name( 063 Function<com.commercetools.history.models.common.LocalizedStringBuilder, com.commercetools.history.models.common.LocalizedStringBuilder> builder) { 064 this.name = builder.apply(com.commercetools.history.models.common.LocalizedStringBuilder.of()).build(); 065 return this; 066 } 067 068 /** 069 * set the value to the name using the builder function 070 * @param builder function to build the name value 071 * @return Builder 072 */ 073 074 public CustomLineItemBuilder withName( 075 Function<com.commercetools.history.models.common.LocalizedStringBuilder, com.commercetools.history.models.common.LocalizedString> builder) { 076 this.name = builder.apply(com.commercetools.history.models.common.LocalizedStringBuilder.of()); 077 return this; 078 } 079 080 /** 081 * set the value to the name 082 * @param name value to be set 083 * @return Builder 084 */ 085 086 public CustomLineItemBuilder name(final com.commercetools.history.models.common.LocalizedString name) { 087 this.name = name; 088 return this; 089 } 090 091 /** 092 * set the value to the money using the builder function 093 * @param builder function to build the money value 094 * @return Builder 095 */ 096 097 public CustomLineItemBuilder money( 098 Function<com.commercetools.history.models.common.MoneyBuilder, com.commercetools.history.models.common.MoneyBuilder> builder) { 099 this.money = builder.apply(com.commercetools.history.models.common.MoneyBuilder.of()).build(); 100 return this; 101 } 102 103 /** 104 * set the value to the money using the builder function 105 * @param builder function to build the money value 106 * @return Builder 107 */ 108 109 public CustomLineItemBuilder withMoney( 110 Function<com.commercetools.history.models.common.MoneyBuilder, com.commercetools.history.models.common.Money> builder) { 111 this.money = builder.apply(com.commercetools.history.models.common.MoneyBuilder.of()); 112 return this; 113 } 114 115 /** 116 * set the value to the money 117 * @param money value to be set 118 * @return Builder 119 */ 120 121 public CustomLineItemBuilder money(final com.commercetools.history.models.common.Money money) { 122 this.money = money; 123 return this; 124 } 125 126 /** 127 * set the value to the taxedPrice using the builder function 128 * @param builder function to build the taxedPrice value 129 * @return Builder 130 */ 131 132 public CustomLineItemBuilder taxedPrice( 133 Function<com.commercetools.history.models.common.TaxedItemPriceBuilder, com.commercetools.history.models.common.TaxedItemPriceBuilder> builder) { 134 this.taxedPrice = builder.apply(com.commercetools.history.models.common.TaxedItemPriceBuilder.of()).build(); 135 return this; 136 } 137 138 /** 139 * set the value to the taxedPrice using the builder function 140 * @param builder function to build the taxedPrice value 141 * @return Builder 142 */ 143 144 public CustomLineItemBuilder withTaxedPrice( 145 Function<com.commercetools.history.models.common.TaxedItemPriceBuilder, com.commercetools.history.models.common.TaxedItemPrice> builder) { 146 this.taxedPrice = builder.apply(com.commercetools.history.models.common.TaxedItemPriceBuilder.of()); 147 return this; 148 } 149 150 /** 151 * set the value to the taxedPrice 152 * @param taxedPrice value to be set 153 * @return Builder 154 */ 155 156 public CustomLineItemBuilder taxedPrice(final com.commercetools.history.models.common.TaxedItemPrice taxedPrice) { 157 this.taxedPrice = taxedPrice; 158 return this; 159 } 160 161 /** 162 * set the value to the totalPrice using the builder function 163 * @param builder function to build the totalPrice value 164 * @return Builder 165 */ 166 167 public CustomLineItemBuilder totalPrice( 168 Function<com.commercetools.history.models.common.MoneyBuilder, com.commercetools.history.models.common.MoneyBuilder> builder) { 169 this.totalPrice = builder.apply(com.commercetools.history.models.common.MoneyBuilder.of()).build(); 170 return this; 171 } 172 173 /** 174 * set the value to the totalPrice using the builder function 175 * @param builder function to build the totalPrice value 176 * @return Builder 177 */ 178 179 public CustomLineItemBuilder withTotalPrice( 180 Function<com.commercetools.history.models.common.MoneyBuilder, com.commercetools.history.models.common.Money> builder) { 181 this.totalPrice = builder.apply(com.commercetools.history.models.common.MoneyBuilder.of()); 182 return this; 183 } 184 185 /** 186 * set the value to the totalPrice 187 * @param totalPrice value to be set 188 * @return Builder 189 */ 190 191 public CustomLineItemBuilder totalPrice(final com.commercetools.history.models.common.Money totalPrice) { 192 this.totalPrice = totalPrice; 193 return this; 194 } 195 196 /** 197 * <p>A unique String in the cart to identify this CustomLineItem.</p> 198 * @param slug value to be set 199 * @return Builder 200 */ 201 202 public CustomLineItemBuilder slug(final String slug) { 203 this.slug = slug; 204 return this; 205 } 206 207 /** 208 * <p>The amount of a CustomLineItem in the cart. Must be a positive integer.</p> 209 * @param quantity value to be set 210 * @return Builder 211 */ 212 213 public CustomLineItemBuilder quantity(final Integer quantity) { 214 this.quantity = quantity; 215 return this; 216 } 217 218 /** 219 * <p>The unique ID of this CustomLineItem.</p> 220 * @return id 221 */ 222 223 public String getId() { 224 return this.id; 225 } 226 227 /** 228 * value of name} 229 * @return name 230 */ 231 232 public com.commercetools.history.models.common.LocalizedString getName() { 233 return this.name; 234 } 235 236 /** 237 * value of money} 238 * @return money 239 */ 240 241 public com.commercetools.history.models.common.Money getMoney() { 242 return this.money; 243 } 244 245 /** 246 * value of taxedPrice} 247 * @return taxedPrice 248 */ 249 250 public com.commercetools.history.models.common.TaxedItemPrice getTaxedPrice() { 251 return this.taxedPrice; 252 } 253 254 /** 255 * value of totalPrice} 256 * @return totalPrice 257 */ 258 259 public com.commercetools.history.models.common.Money getTotalPrice() { 260 return this.totalPrice; 261 } 262 263 /** 264 * <p>A unique String in the cart to identify this CustomLineItem.</p> 265 * @return slug 266 */ 267 268 public String getSlug() { 269 return this.slug; 270 } 271 272 /** 273 * <p>The amount of a CustomLineItem in the cart. Must be a positive integer.</p> 274 * @return quantity 275 */ 276 277 public Integer getQuantity() { 278 return this.quantity; 279 } 280 281 /** 282 * builds CustomLineItem with checking for non-null required values 283 * @return CustomLineItem 284 */ 285 public CustomLineItem build() { 286 Objects.requireNonNull(id, CustomLineItem.class + ": id is missing"); 287 Objects.requireNonNull(name, CustomLineItem.class + ": name is missing"); 288 Objects.requireNonNull(money, CustomLineItem.class + ": money is missing"); 289 Objects.requireNonNull(taxedPrice, CustomLineItem.class + ": taxedPrice is missing"); 290 Objects.requireNonNull(totalPrice, CustomLineItem.class + ": totalPrice is missing"); 291 Objects.requireNonNull(slug, CustomLineItem.class + ": slug is missing"); 292 Objects.requireNonNull(quantity, CustomLineItem.class + ": quantity is missing"); 293 return new CustomLineItemImpl(id, name, money, taxedPrice, totalPrice, slug, quantity); 294 } 295 296 /** 297 * builds CustomLineItem without checking for non-null required values 298 * @return CustomLineItem 299 */ 300 public CustomLineItem buildUnchecked() { 301 return new CustomLineItemImpl(id, name, money, taxedPrice, totalPrice, slug, quantity); 302 } 303 304 /** 305 * factory method for an instance of CustomLineItemBuilder 306 * @return builder 307 */ 308 public static CustomLineItemBuilder of() { 309 return new CustomLineItemBuilder(); 310 } 311 312 /** 313 * create builder for CustomLineItem instance 314 * @param template instance with prefilled values for the builder 315 * @return builder 316 */ 317 public static CustomLineItemBuilder of(final CustomLineItem template) { 318 CustomLineItemBuilder builder = new CustomLineItemBuilder(); 319 builder.id = template.getId(); 320 builder.name = template.getName(); 321 builder.money = template.getMoney(); 322 builder.taxedPrice = template.getTaxedPrice(); 323 builder.totalPrice = template.getTotalPrice(); 324 builder.slug = template.getSlug(); 325 builder.quantity = template.getQuantity(); 326 return builder; 327 } 328 329}