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 * TaxedPriceBuilder 012 * <hr> 013 * Example to create an instance using the builder pattern 014 * <div class=code-example> 015 * <pre><code class='java'> 016 * TaxedPrice taxedPrice = TaxedPrice.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 TaxedPriceBuilder implements Builder<TaxedPrice> { 025 026 private com.commercetools.history.models.common.Money totalNet; 027 028 private com.commercetools.history.models.common.Money totalGross; 029 030 /** 031 * <p>Total net price of the Order.</p> 032 * @param builder function to build the totalNet value 033 * @return Builder 034 */ 035 036 public TaxedPriceBuilder 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 * <p>Total net price of the Order.</p> 044 * @param builder function to build the totalNet value 045 * @return Builder 046 */ 047 048 public TaxedPriceBuilder 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 * <p>Total net price of the Order.</p> 056 * @param totalNet value to be set 057 * @return Builder 058 */ 059 060 public TaxedPriceBuilder totalNet(final com.commercetools.history.models.common.Money totalNet) { 061 this.totalNet = totalNet; 062 return this; 063 } 064 065 /** 066 * <p>Total gross price of the Order.</p> 067 * @param builder function to build the totalGross value 068 * @return Builder 069 */ 070 071 public TaxedPriceBuilder 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 * <p>Total gross price of the Order.</p> 079 * @param builder function to build the totalGross value 080 * @return Builder 081 */ 082 083 public TaxedPriceBuilder 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 * <p>Total gross price of the Order.</p> 091 * @param totalGross value to be set 092 * @return Builder 093 */ 094 095 public TaxedPriceBuilder totalGross(final com.commercetools.history.models.common.Money totalGross) { 096 this.totalGross = totalGross; 097 return this; 098 } 099 100 /** 101 * <p>Total net price of the Order.</p> 102 * @return totalNet 103 */ 104 105 public com.commercetools.history.models.common.Money getTotalNet() { 106 return this.totalNet; 107 } 108 109 /** 110 * <p>Total gross price of the Order.</p> 111 * @return totalGross 112 */ 113 114 public com.commercetools.history.models.common.Money getTotalGross() { 115 return this.totalGross; 116 } 117 118 /** 119 * builds TaxedPrice with checking for non-null required values 120 * @return TaxedPrice 121 */ 122 public TaxedPrice build() { 123 Objects.requireNonNull(totalNet, TaxedPrice.class + ": totalNet is missing"); 124 Objects.requireNonNull(totalGross, TaxedPrice.class + ": totalGross is missing"); 125 return new TaxedPriceImpl(totalNet, totalGross); 126 } 127 128 /** 129 * builds TaxedPrice without checking for non-null required values 130 * @return TaxedPrice 131 */ 132 public TaxedPrice buildUnchecked() { 133 return new TaxedPriceImpl(totalNet, totalGross); 134 } 135 136 /** 137 * factory method for an instance of TaxedPriceBuilder 138 * @return builder 139 */ 140 public static TaxedPriceBuilder of() { 141 return new TaxedPriceBuilder(); 142 } 143 144 /** 145 * create builder for TaxedPrice instance 146 * @param template instance with prefilled values for the builder 147 * @return builder 148 */ 149 public static TaxedPriceBuilder of(final TaxedPrice template) { 150 TaxedPriceBuilder builder = new TaxedPriceBuilder(); 151 builder.totalNet = template.getTotalNet(); 152 builder.totalGross = template.getTotalGross(); 153 return builder; 154 } 155 156}