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