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 * TaxedItemPriceBuilder 012 * <hr> 013 * Example to create an instance using the builder pattern 014 * <div class=code-example> 015 * <pre><code class='java'> 016 * TaxedItemPrice taxedItemPrice = TaxedItemPrice.builder() 017 * .totalNet(totalNetBuilder -> totalNetBuilder) 018 * .totalGross(totalGrossBuilder -> totalGrossBuilder) 019 * .build() 020 * </code></pre> 021 * </div> 022 */ 023@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen") 024public class TaxedItemPriceBuilder implements Builder<TaxedItemPrice> { 025 026 private com.commercetools.history.models.common.Money totalNet; 027 028 private com.commercetools.history.models.common.Money totalGross; 029 030 /** 031 * set the value to the totalNet using the builder function 032 * @param builder function to build the totalNet value 033 * @return Builder 034 */ 035 036 public TaxedItemPriceBuilder totalNet( 037 Function<com.commercetools.history.models.common.MoneyBuilder, com.commercetools.history.models.common.MoneyBuilder> builder) { 038 this.totalNet = builder.apply(com.commercetools.history.models.common.MoneyBuilder.of()).build(); 039 return this; 040 } 041 042 /** 043 * set the value to the totalNet using the builder function 044 * @param builder function to build the totalNet value 045 * @return Builder 046 */ 047 048 public TaxedItemPriceBuilder withTotalNet( 049 Function<com.commercetools.history.models.common.MoneyBuilder, com.commercetools.history.models.common.Money> builder) { 050 this.totalNet = builder.apply(com.commercetools.history.models.common.MoneyBuilder.of()); 051 return this; 052 } 053 054 /** 055 * set the value to the totalNet 056 * @param totalNet value to be set 057 * @return Builder 058 */ 059 060 public TaxedItemPriceBuilder totalNet(final com.commercetools.history.models.common.Money totalNet) { 061 this.totalNet = totalNet; 062 return this; 063 } 064 065 /** 066 * set the value to the totalGross using the builder function 067 * @param builder function to build the totalGross value 068 * @return Builder 069 */ 070 071 public TaxedItemPriceBuilder totalGross( 072 Function<com.commercetools.history.models.common.MoneyBuilder, com.commercetools.history.models.common.MoneyBuilder> builder) { 073 this.totalGross = builder.apply(com.commercetools.history.models.common.MoneyBuilder.of()).build(); 074 return this; 075 } 076 077 /** 078 * set the value to the totalGross using the builder function 079 * @param builder function to build the totalGross value 080 * @return Builder 081 */ 082 083 public TaxedItemPriceBuilder withTotalGross( 084 Function<com.commercetools.history.models.common.MoneyBuilder, com.commercetools.history.models.common.Money> builder) { 085 this.totalGross = builder.apply(com.commercetools.history.models.common.MoneyBuilder.of()); 086 return this; 087 } 088 089 /** 090 * set the value to the totalGross 091 * @param totalGross value to be set 092 * @return Builder 093 */ 094 095 public TaxedItemPriceBuilder totalGross(final com.commercetools.history.models.common.Money totalGross) { 096 this.totalGross = totalGross; 097 return this; 098 } 099 100 /** 101 * value of totalNet} 102 * @return totalNet 103 */ 104 105 public com.commercetools.history.models.common.Money getTotalNet() { 106 return this.totalNet; 107 } 108 109 /** 110 * value of totalGross} 111 * @return totalGross 112 */ 113 114 public com.commercetools.history.models.common.Money getTotalGross() { 115 return this.totalGross; 116 } 117 118 /** 119 * builds TaxedItemPrice with checking for non-null required values 120 * @return TaxedItemPrice 121 */ 122 public TaxedItemPrice build() { 123 Objects.requireNonNull(totalNet, TaxedItemPrice.class + ": totalNet is missing"); 124 Objects.requireNonNull(totalGross, TaxedItemPrice.class + ": totalGross is missing"); 125 return new TaxedItemPriceImpl(totalNet, totalGross); 126 } 127 128 /** 129 * builds TaxedItemPrice without checking for non-null required values 130 * @return TaxedItemPrice 131 */ 132 public TaxedItemPrice buildUnchecked() { 133 return new TaxedItemPriceImpl(totalNet, totalGross); 134 } 135 136 /** 137 * factory method for an instance of TaxedItemPriceBuilder 138 * @return builder 139 */ 140 public static TaxedItemPriceBuilder of() { 141 return new TaxedItemPriceBuilder(); 142 } 143 144 /** 145 * create builder for TaxedItemPrice instance 146 * @param template instance with prefilled values for the builder 147 * @return builder 148 */ 149 public static TaxedItemPriceBuilder of(final TaxedItemPrice template) { 150 TaxedItemPriceBuilder builder = new TaxedItemPriceBuilder(); 151 builder.totalNet = template.getTotalNet(); 152 builder.totalGross = template.getTotalGross(); 153 return builder; 154 } 155 156}