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 * ChangeShoppingListLineItemsOrderChangeBuilder 012 * <hr> 013 * Example to create an instance using the builder pattern 014 * <div class=code-example> 015 * <pre><code class='java'> 016 * ChangeShoppingListLineItemsOrderChange changeShoppingListLineItemsOrderChange = ChangeShoppingListLineItemsOrderChange.builder() 017 * .change("{change}") 018 * .plusPreviousValue(previousValueBuilder -> previousValueBuilder) 019 * .plusNextValue(nextValueBuilder -> nextValueBuilder) 020 * .build() 021 * </code></pre> 022 * </div> 023 */ 024@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen") 025public class ChangeShoppingListLineItemsOrderChangeBuilder implements Builder<ChangeShoppingListLineItemsOrderChange> { 026 027 private String change; 028 029 private java.util.List<com.commercetools.history.models.change_value.ShoppingListLineItemValue> previousValue; 030 031 private java.util.List<com.commercetools.history.models.change_value.ShoppingListLineItemValue> nextValue; 032 033 /** 034 * set the value to the change 035 * @param change value to be set 036 * @return Builder 037 */ 038 039 public ChangeShoppingListLineItemsOrderChangeBuilder change(final String change) { 040 this.change = change; 041 return this; 042 } 043 044 /** 045 * <p>Value before the change.</p> 046 * @param previousValue value to be set 047 * @return Builder 048 */ 049 050 public ChangeShoppingListLineItemsOrderChangeBuilder previousValue( 051 final com.commercetools.history.models.change_value.ShoppingListLineItemValue... previousValue) { 052 this.previousValue = new ArrayList<>(Arrays.asList(previousValue)); 053 return this; 054 } 055 056 /** 057 * <p>Value before the change.</p> 058 * @param previousValue value to be set 059 * @return Builder 060 */ 061 062 public ChangeShoppingListLineItemsOrderChangeBuilder previousValue( 063 final java.util.List<com.commercetools.history.models.change_value.ShoppingListLineItemValue> previousValue) { 064 this.previousValue = previousValue; 065 return this; 066 } 067 068 /** 069 * <p>Value before the change.</p> 070 * @param previousValue value to be set 071 * @return Builder 072 */ 073 074 public ChangeShoppingListLineItemsOrderChangeBuilder plusPreviousValue( 075 final com.commercetools.history.models.change_value.ShoppingListLineItemValue... previousValue) { 076 if (this.previousValue == null) { 077 this.previousValue = new ArrayList<>(); 078 } 079 this.previousValue.addAll(Arrays.asList(previousValue)); 080 return this; 081 } 082 083 /** 084 * <p>Value before the change.</p> 085 * @param builder function to build the previousValue value 086 * @return Builder 087 */ 088 089 public ChangeShoppingListLineItemsOrderChangeBuilder plusPreviousValue( 090 Function<com.commercetools.history.models.change_value.ShoppingListLineItemValueBuilder, com.commercetools.history.models.change_value.ShoppingListLineItemValueBuilder> builder) { 091 if (this.previousValue == null) { 092 this.previousValue = new ArrayList<>(); 093 } 094 this.previousValue.add( 095 builder.apply(com.commercetools.history.models.change_value.ShoppingListLineItemValueBuilder.of()).build()); 096 return this; 097 } 098 099 /** 100 * <p>Value before the change.</p> 101 * @param builder function to build the previousValue value 102 * @return Builder 103 */ 104 105 public ChangeShoppingListLineItemsOrderChangeBuilder withPreviousValue( 106 Function<com.commercetools.history.models.change_value.ShoppingListLineItemValueBuilder, com.commercetools.history.models.change_value.ShoppingListLineItemValueBuilder> builder) { 107 this.previousValue = new ArrayList<>(); 108 this.previousValue.add( 109 builder.apply(com.commercetools.history.models.change_value.ShoppingListLineItemValueBuilder.of()).build()); 110 return this; 111 } 112 113 /** 114 * <p>Value before the change.</p> 115 * @param builder function to build the previousValue value 116 * @return Builder 117 */ 118 119 public ChangeShoppingListLineItemsOrderChangeBuilder addPreviousValue( 120 Function<com.commercetools.history.models.change_value.ShoppingListLineItemValueBuilder, com.commercetools.history.models.change_value.ShoppingListLineItemValue> builder) { 121 return plusPreviousValue( 122 builder.apply(com.commercetools.history.models.change_value.ShoppingListLineItemValueBuilder.of())); 123 } 124 125 /** 126 * <p>Value before the change.</p> 127 * @param builder function to build the previousValue value 128 * @return Builder 129 */ 130 131 public ChangeShoppingListLineItemsOrderChangeBuilder setPreviousValue( 132 Function<com.commercetools.history.models.change_value.ShoppingListLineItemValueBuilder, com.commercetools.history.models.change_value.ShoppingListLineItemValue> builder) { 133 return previousValue( 134 builder.apply(com.commercetools.history.models.change_value.ShoppingListLineItemValueBuilder.of())); 135 } 136 137 /** 138 * <p>Value after the change.</p> 139 * @param nextValue value to be set 140 * @return Builder 141 */ 142 143 public ChangeShoppingListLineItemsOrderChangeBuilder nextValue( 144 final com.commercetools.history.models.change_value.ShoppingListLineItemValue... nextValue) { 145 this.nextValue = new ArrayList<>(Arrays.asList(nextValue)); 146 return this; 147 } 148 149 /** 150 * <p>Value after the change.</p> 151 * @param nextValue value to be set 152 * @return Builder 153 */ 154 155 public ChangeShoppingListLineItemsOrderChangeBuilder nextValue( 156 final java.util.List<com.commercetools.history.models.change_value.ShoppingListLineItemValue> nextValue) { 157 this.nextValue = nextValue; 158 return this; 159 } 160 161 /** 162 * <p>Value after the change.</p> 163 * @param nextValue value to be set 164 * @return Builder 165 */ 166 167 public ChangeShoppingListLineItemsOrderChangeBuilder plusNextValue( 168 final com.commercetools.history.models.change_value.ShoppingListLineItemValue... nextValue) { 169 if (this.nextValue == null) { 170 this.nextValue = new ArrayList<>(); 171 } 172 this.nextValue.addAll(Arrays.asList(nextValue)); 173 return this; 174 } 175 176 /** 177 * <p>Value after the change.</p> 178 * @param builder function to build the nextValue value 179 * @return Builder 180 */ 181 182 public ChangeShoppingListLineItemsOrderChangeBuilder plusNextValue( 183 Function<com.commercetools.history.models.change_value.ShoppingListLineItemValueBuilder, com.commercetools.history.models.change_value.ShoppingListLineItemValueBuilder> builder) { 184 if (this.nextValue == null) { 185 this.nextValue = new ArrayList<>(); 186 } 187 this.nextValue.add( 188 builder.apply(com.commercetools.history.models.change_value.ShoppingListLineItemValueBuilder.of()).build()); 189 return this; 190 } 191 192 /** 193 * <p>Value after the change.</p> 194 * @param builder function to build the nextValue value 195 * @return Builder 196 */ 197 198 public ChangeShoppingListLineItemsOrderChangeBuilder withNextValue( 199 Function<com.commercetools.history.models.change_value.ShoppingListLineItemValueBuilder, com.commercetools.history.models.change_value.ShoppingListLineItemValueBuilder> builder) { 200 this.nextValue = new ArrayList<>(); 201 this.nextValue.add( 202 builder.apply(com.commercetools.history.models.change_value.ShoppingListLineItemValueBuilder.of()).build()); 203 return this; 204 } 205 206 /** 207 * <p>Value after the change.</p> 208 * @param builder function to build the nextValue value 209 * @return Builder 210 */ 211 212 public ChangeShoppingListLineItemsOrderChangeBuilder addNextValue( 213 Function<com.commercetools.history.models.change_value.ShoppingListLineItemValueBuilder, com.commercetools.history.models.change_value.ShoppingListLineItemValue> builder) { 214 return plusNextValue( 215 builder.apply(com.commercetools.history.models.change_value.ShoppingListLineItemValueBuilder.of())); 216 } 217 218 /** 219 * <p>Value after the change.</p> 220 * @param builder function to build the nextValue value 221 * @return Builder 222 */ 223 224 public ChangeShoppingListLineItemsOrderChangeBuilder setNextValue( 225 Function<com.commercetools.history.models.change_value.ShoppingListLineItemValueBuilder, com.commercetools.history.models.change_value.ShoppingListLineItemValue> builder) { 226 return nextValue( 227 builder.apply(com.commercetools.history.models.change_value.ShoppingListLineItemValueBuilder.of())); 228 } 229 230 /** 231 * value of change} 232 * @return change 233 */ 234 235 public String getChange() { 236 return this.change; 237 } 238 239 /** 240 * <p>Value before the change.</p> 241 * @return previousValue 242 */ 243 244 public java.util.List<com.commercetools.history.models.change_value.ShoppingListLineItemValue> getPreviousValue() { 245 return this.previousValue; 246 } 247 248 /** 249 * <p>Value after the change.</p> 250 * @return nextValue 251 */ 252 253 public java.util.List<com.commercetools.history.models.change_value.ShoppingListLineItemValue> getNextValue() { 254 return this.nextValue; 255 } 256 257 /** 258 * builds ChangeShoppingListLineItemsOrderChange with checking for non-null required values 259 * @return ChangeShoppingListLineItemsOrderChange 260 */ 261 public ChangeShoppingListLineItemsOrderChange build() { 262 Objects.requireNonNull(change, ChangeShoppingListLineItemsOrderChange.class + ": change is missing"); 263 Objects.requireNonNull(previousValue, 264 ChangeShoppingListLineItemsOrderChange.class + ": previousValue is missing"); 265 Objects.requireNonNull(nextValue, ChangeShoppingListLineItemsOrderChange.class + ": nextValue is missing"); 266 return new ChangeShoppingListLineItemsOrderChangeImpl(change, previousValue, nextValue); 267 } 268 269 /** 270 * builds ChangeShoppingListLineItemsOrderChange without checking for non-null required values 271 * @return ChangeShoppingListLineItemsOrderChange 272 */ 273 public ChangeShoppingListLineItemsOrderChange buildUnchecked() { 274 return new ChangeShoppingListLineItemsOrderChangeImpl(change, previousValue, nextValue); 275 } 276 277 /** 278 * factory method for an instance of ChangeShoppingListLineItemsOrderChangeBuilder 279 * @return builder 280 */ 281 public static ChangeShoppingListLineItemsOrderChangeBuilder of() { 282 return new ChangeShoppingListLineItemsOrderChangeBuilder(); 283 } 284 285 /** 286 * create builder for ChangeShoppingListLineItemsOrderChange instance 287 * @param template instance with prefilled values for the builder 288 * @return builder 289 */ 290 public static ChangeShoppingListLineItemsOrderChangeBuilder of( 291 final ChangeShoppingListLineItemsOrderChange template) { 292 ChangeShoppingListLineItemsOrderChangeBuilder builder = new ChangeShoppingListLineItemsOrderChangeBuilder(); 293 builder.change = template.getChange(); 294 builder.previousValue = template.getPreviousValue(); 295 builder.nextValue = template.getNextValue(); 296 return builder; 297 } 298 299}