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