001 002package com.commercetools.history.models.change; 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 * SetLineItemPriceChangeBuilder 012 * <hr> 013 * Example to create an instance using the builder pattern 014 * <div class=code-example> 015 * <pre><code class='java'> 016 * SetLineItemPriceChange setLineItemPriceChange = SetLineItemPriceChange.builder() 017 * .change("{change}") 018 * .previousValue(previousValueBuilder -> previousValueBuilder) 019 * .nextValue(nextValueBuilder -> nextValueBuilder) 020 * .lineItem(lineItemBuilder -> lineItemBuilder) 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 SetLineItemPriceChangeBuilder implements Builder<SetLineItemPriceChange> { 027 028 private String change; 029 030 private com.commercetools.history.models.common.Price previousValue; 031 032 private com.commercetools.history.models.common.Price nextValue; 033 034 private com.commercetools.history.models.common.LocalizedString lineItem; 035 036 /** 037 * set the value to the change 038 * @param change value to be set 039 * @return Builder 040 */ 041 042 public SetLineItemPriceChangeBuilder change(final String change) { 043 this.change = change; 044 return this; 045 } 046 047 /** 048 * <p>Value before the change.</p> 049 * @param builder function to build the previousValue value 050 * @return Builder 051 */ 052 053 public SetLineItemPriceChangeBuilder previousValue( 054 Function<com.commercetools.history.models.common.PriceBuilder, com.commercetools.history.models.common.PriceBuilder> builder) { 055 this.previousValue = builder.apply(com.commercetools.history.models.common.PriceBuilder.of()).build(); 056 return this; 057 } 058 059 /** 060 * <p>Value before the change.</p> 061 * @param builder function to build the previousValue value 062 * @return Builder 063 */ 064 065 public SetLineItemPriceChangeBuilder withPreviousValue( 066 Function<com.commercetools.history.models.common.PriceBuilder, com.commercetools.history.models.common.Price> builder) { 067 this.previousValue = builder.apply(com.commercetools.history.models.common.PriceBuilder.of()); 068 return this; 069 } 070 071 /** 072 * <p>Value before the change.</p> 073 * @param previousValue value to be set 074 * @return Builder 075 */ 076 077 public SetLineItemPriceChangeBuilder previousValue( 078 final com.commercetools.history.models.common.Price previousValue) { 079 this.previousValue = previousValue; 080 return this; 081 } 082 083 /** 084 * <p>Value after the change.</p> 085 * @param builder function to build the nextValue value 086 * @return Builder 087 */ 088 089 public SetLineItemPriceChangeBuilder nextValue( 090 Function<com.commercetools.history.models.common.PriceBuilder, com.commercetools.history.models.common.PriceBuilder> builder) { 091 this.nextValue = builder.apply(com.commercetools.history.models.common.PriceBuilder.of()).build(); 092 return this; 093 } 094 095 /** 096 * <p>Value after the change.</p> 097 * @param builder function to build the nextValue value 098 * @return Builder 099 */ 100 101 public SetLineItemPriceChangeBuilder withNextValue( 102 Function<com.commercetools.history.models.common.PriceBuilder, com.commercetools.history.models.common.Price> builder) { 103 this.nextValue = builder.apply(com.commercetools.history.models.common.PriceBuilder.of()); 104 return this; 105 } 106 107 /** 108 * <p>Value after the change.</p> 109 * @param nextValue value to be set 110 * @return Builder 111 */ 112 113 public SetLineItemPriceChangeBuilder nextValue(final com.commercetools.history.models.common.Price nextValue) { 114 this.nextValue = nextValue; 115 return this; 116 } 117 118 /** 119 * <p>Name of the Product the updated Line Item is based on.</p> 120 * @param builder function to build the lineItem value 121 * @return Builder 122 */ 123 124 public SetLineItemPriceChangeBuilder lineItem( 125 Function<com.commercetools.history.models.common.LocalizedStringBuilder, com.commercetools.history.models.common.LocalizedStringBuilder> builder) { 126 this.lineItem = builder.apply(com.commercetools.history.models.common.LocalizedStringBuilder.of()).build(); 127 return this; 128 } 129 130 /** 131 * <p>Name of the Product the updated Line Item is based on.</p> 132 * @param builder function to build the lineItem value 133 * @return Builder 134 */ 135 136 public SetLineItemPriceChangeBuilder withLineItem( 137 Function<com.commercetools.history.models.common.LocalizedStringBuilder, com.commercetools.history.models.common.LocalizedString> builder) { 138 this.lineItem = builder.apply(com.commercetools.history.models.common.LocalizedStringBuilder.of()); 139 return this; 140 } 141 142 /** 143 * <p>Name of the Product the updated Line Item is based on.</p> 144 * @param lineItem value to be set 145 * @return Builder 146 */ 147 148 public SetLineItemPriceChangeBuilder lineItem( 149 final com.commercetools.history.models.common.LocalizedString lineItem) { 150 this.lineItem = lineItem; 151 return this; 152 } 153 154 /** 155 * value of change} 156 * @return change 157 */ 158 159 public String getChange() { 160 return this.change; 161 } 162 163 /** 164 * <p>Value before the change.</p> 165 * @return previousValue 166 */ 167 168 public com.commercetools.history.models.common.Price getPreviousValue() { 169 return this.previousValue; 170 } 171 172 /** 173 * <p>Value after the change.</p> 174 * @return nextValue 175 */ 176 177 public com.commercetools.history.models.common.Price getNextValue() { 178 return this.nextValue; 179 } 180 181 /** 182 * <p>Name of the Product the updated Line Item is based on.</p> 183 * @return lineItem 184 */ 185 186 public com.commercetools.history.models.common.LocalizedString getLineItem() { 187 return this.lineItem; 188 } 189 190 /** 191 * builds SetLineItemPriceChange with checking for non-null required values 192 * @return SetLineItemPriceChange 193 */ 194 public SetLineItemPriceChange build() { 195 Objects.requireNonNull(change, SetLineItemPriceChange.class + ": change is missing"); 196 Objects.requireNonNull(previousValue, SetLineItemPriceChange.class + ": previousValue is missing"); 197 Objects.requireNonNull(nextValue, SetLineItemPriceChange.class + ": nextValue is missing"); 198 Objects.requireNonNull(lineItem, SetLineItemPriceChange.class + ": lineItem is missing"); 199 return new SetLineItemPriceChangeImpl(change, previousValue, nextValue, lineItem); 200 } 201 202 /** 203 * builds SetLineItemPriceChange without checking for non-null required values 204 * @return SetLineItemPriceChange 205 */ 206 public SetLineItemPriceChange buildUnchecked() { 207 return new SetLineItemPriceChangeImpl(change, previousValue, nextValue, lineItem); 208 } 209 210 /** 211 * factory method for an instance of SetLineItemPriceChangeBuilder 212 * @return builder 213 */ 214 public static SetLineItemPriceChangeBuilder of() { 215 return new SetLineItemPriceChangeBuilder(); 216 } 217 218 /** 219 * create builder for SetLineItemPriceChange instance 220 * @param template instance with prefilled values for the builder 221 * @return builder 222 */ 223 public static SetLineItemPriceChangeBuilder of(final SetLineItemPriceChange template) { 224 SetLineItemPriceChangeBuilder builder = new SetLineItemPriceChangeBuilder(); 225 builder.change = template.getChange(); 226 builder.previousValue = template.getPreviousValue(); 227 builder.nextValue = template.getNextValue(); 228 builder.lineItem = template.getLineItem(); 229 return builder; 230 } 231 232}