001 002package com.commercetools.api.models.zone; 003 004import java.util.*; 005import java.util.function.Function; 006 007import javax.annotation.Nullable; 008 009import io.vrap.rmf.base.client.Builder; 010import io.vrap.rmf.base.client.utils.Generated; 011 012/** 013 * ZoneBuilder 014 * <hr> 015 * Example to create an instance using the builder pattern 016 * <div class=code-example> 017 * <pre><code class='java'> 018 * Zone zone = Zone.builder() 019 * .id("{id}") 020 * .version(0.3) 021 * .createdAt(ZonedDateTime.parse("2022-01-01T12:00:00.301Z")) 022 * .lastModifiedAt(ZonedDateTime.parse("2022-01-01T12:00:00.301Z")) 023 * .name("{name}") 024 * .plusLocations(locationsBuilder -> locationsBuilder) 025 * .build() 026 * </code></pre> 027 * </div> 028 */ 029@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen") 030public class ZoneBuilder implements Builder<Zone> { 031 032 private String id; 033 034 private Long version; 035 036 private java.time.ZonedDateTime createdAt; 037 038 private java.time.ZonedDateTime lastModifiedAt; 039 040 @Nullable 041 private com.commercetools.api.models.common.LastModifiedBy lastModifiedBy; 042 043 @Nullable 044 private com.commercetools.api.models.common.CreatedBy createdBy; 045 046 @Nullable 047 private String key; 048 049 private String name; 050 051 @Nullable 052 private String description; 053 054 private java.util.List<com.commercetools.api.models.zone.Location> locations; 055 056 /** 057 * <p>Unique identifier of the Zone.</p> 058 * @param id value to be set 059 * @return Builder 060 */ 061 062 public ZoneBuilder id(final String id) { 063 this.id = id; 064 return this; 065 } 066 067 /** 068 * <p>Current version of the Zone.</p> 069 * @param version value to be set 070 * @return Builder 071 */ 072 073 public ZoneBuilder version(final Long version) { 074 this.version = version; 075 return this; 076 } 077 078 /** 079 * <p>Date and time (UTC) the Zone was initially created.</p> 080 * @param createdAt value to be set 081 * @return Builder 082 */ 083 084 public ZoneBuilder createdAt(final java.time.ZonedDateTime createdAt) { 085 this.createdAt = createdAt; 086 return this; 087 } 088 089 /** 090 * <p>Date and time (UTC) the Zone was last updated.</p> 091 * @param lastModifiedAt value to be set 092 * @return Builder 093 */ 094 095 public ZoneBuilder lastModifiedAt(final java.time.ZonedDateTime lastModifiedAt) { 096 this.lastModifiedAt = lastModifiedAt; 097 return this; 098 } 099 100 /** 101 * <p>Present on resources created after 1 February 2019 except for events not tracked.</p> 102 * @param builder function to build the lastModifiedBy value 103 * @return Builder 104 */ 105 106 public ZoneBuilder lastModifiedBy( 107 Function<com.commercetools.api.models.common.LastModifiedByBuilder, com.commercetools.api.models.common.LastModifiedByBuilder> builder) { 108 this.lastModifiedBy = builder.apply(com.commercetools.api.models.common.LastModifiedByBuilder.of()).build(); 109 return this; 110 } 111 112 /** 113 * <p>Present on resources created after 1 February 2019 except for events not tracked.</p> 114 * @param builder function to build the lastModifiedBy value 115 * @return Builder 116 */ 117 118 public ZoneBuilder withLastModifiedBy( 119 Function<com.commercetools.api.models.common.LastModifiedByBuilder, com.commercetools.api.models.common.LastModifiedBy> builder) { 120 this.lastModifiedBy = builder.apply(com.commercetools.api.models.common.LastModifiedByBuilder.of()); 121 return this; 122 } 123 124 /** 125 * <p>Present on resources created after 1 February 2019 except for events not tracked.</p> 126 * @param lastModifiedBy value to be set 127 * @return Builder 128 */ 129 130 public ZoneBuilder lastModifiedBy( 131 @Nullable final com.commercetools.api.models.common.LastModifiedBy lastModifiedBy) { 132 this.lastModifiedBy = lastModifiedBy; 133 return this; 134 } 135 136 /** 137 * <p>Present on resources created after 1 February 2019 except for events not tracked.</p> 138 * @param builder function to build the createdBy value 139 * @return Builder 140 */ 141 142 public ZoneBuilder createdBy( 143 Function<com.commercetools.api.models.common.CreatedByBuilder, com.commercetools.api.models.common.CreatedByBuilder> builder) { 144 this.createdBy = builder.apply(com.commercetools.api.models.common.CreatedByBuilder.of()).build(); 145 return this; 146 } 147 148 /** 149 * <p>Present on resources created after 1 February 2019 except for events not tracked.</p> 150 * @param builder function to build the createdBy value 151 * @return Builder 152 */ 153 154 public ZoneBuilder withCreatedBy( 155 Function<com.commercetools.api.models.common.CreatedByBuilder, com.commercetools.api.models.common.CreatedBy> builder) { 156 this.createdBy = builder.apply(com.commercetools.api.models.common.CreatedByBuilder.of()); 157 return this; 158 } 159 160 /** 161 * <p>Present on resources created after 1 February 2019 except for events not tracked.</p> 162 * @param createdBy value to be set 163 * @return Builder 164 */ 165 166 public ZoneBuilder createdBy(@Nullable final com.commercetools.api.models.common.CreatedBy createdBy) { 167 this.createdBy = createdBy; 168 return this; 169 } 170 171 /** 172 * <p>User-defined unique identifier of the Zone.</p> 173 * @param key value to be set 174 * @return Builder 175 */ 176 177 public ZoneBuilder key(@Nullable final String key) { 178 this.key = key; 179 return this; 180 } 181 182 /** 183 * <p>Name of the Zone.</p> 184 * @param name value to be set 185 * @return Builder 186 */ 187 188 public ZoneBuilder name(final String name) { 189 this.name = name; 190 return this; 191 } 192 193 /** 194 * <p>Description of the Zone.</p> 195 * @param description value to be set 196 * @return Builder 197 */ 198 199 public ZoneBuilder description(@Nullable final String description) { 200 this.description = description; 201 return this; 202 } 203 204 /** 205 * <p>List of locations that belong to the Zone.</p> 206 * @param locations value to be set 207 * @return Builder 208 */ 209 210 public ZoneBuilder locations(final com.commercetools.api.models.zone.Location... locations) { 211 this.locations = new ArrayList<>(Arrays.asList(locations)); 212 return this; 213 } 214 215 /** 216 * <p>List of locations that belong to the Zone.</p> 217 * @param locations value to be set 218 * @return Builder 219 */ 220 221 public ZoneBuilder locations(final java.util.List<com.commercetools.api.models.zone.Location> locations) { 222 this.locations = locations; 223 return this; 224 } 225 226 /** 227 * <p>List of locations that belong to the Zone.</p> 228 * @param locations value to be set 229 * @return Builder 230 */ 231 232 public ZoneBuilder plusLocations(final com.commercetools.api.models.zone.Location... locations) { 233 if (this.locations == null) { 234 this.locations = new ArrayList<>(); 235 } 236 this.locations.addAll(Arrays.asList(locations)); 237 return this; 238 } 239 240 /** 241 * <p>List of locations that belong to the Zone.</p> 242 * @param builder function to build the locations value 243 * @return Builder 244 */ 245 246 public ZoneBuilder plusLocations( 247 Function<com.commercetools.api.models.zone.LocationBuilder, com.commercetools.api.models.zone.LocationBuilder> builder) { 248 if (this.locations == null) { 249 this.locations = new ArrayList<>(); 250 } 251 this.locations.add(builder.apply(com.commercetools.api.models.zone.LocationBuilder.of()).build()); 252 return this; 253 } 254 255 /** 256 * <p>List of locations that belong to the Zone.</p> 257 * @param builder function to build the locations value 258 * @return Builder 259 */ 260 261 public ZoneBuilder withLocations( 262 Function<com.commercetools.api.models.zone.LocationBuilder, com.commercetools.api.models.zone.LocationBuilder> builder) { 263 this.locations = new ArrayList<>(); 264 this.locations.add(builder.apply(com.commercetools.api.models.zone.LocationBuilder.of()).build()); 265 return this; 266 } 267 268 /** 269 * <p>List of locations that belong to the Zone.</p> 270 * @param builder function to build the locations value 271 * @return Builder 272 */ 273 274 public ZoneBuilder addLocations( 275 Function<com.commercetools.api.models.zone.LocationBuilder, com.commercetools.api.models.zone.Location> builder) { 276 return plusLocations(builder.apply(com.commercetools.api.models.zone.LocationBuilder.of())); 277 } 278 279 /** 280 * <p>List of locations that belong to the Zone.</p> 281 * @param builder function to build the locations value 282 * @return Builder 283 */ 284 285 public ZoneBuilder setLocations( 286 Function<com.commercetools.api.models.zone.LocationBuilder, com.commercetools.api.models.zone.Location> builder) { 287 return locations(builder.apply(com.commercetools.api.models.zone.LocationBuilder.of())); 288 } 289 290 /** 291 * <p>Unique identifier of the Zone.</p> 292 * @return id 293 */ 294 295 public String getId() { 296 return this.id; 297 } 298 299 /** 300 * <p>Current version of the Zone.</p> 301 * @return version 302 */ 303 304 public Long getVersion() { 305 return this.version; 306 } 307 308 /** 309 * <p>Date and time (UTC) the Zone was initially created.</p> 310 * @return createdAt 311 */ 312 313 public java.time.ZonedDateTime getCreatedAt() { 314 return this.createdAt; 315 } 316 317 /** 318 * <p>Date and time (UTC) the Zone was last updated.</p> 319 * @return lastModifiedAt 320 */ 321 322 public java.time.ZonedDateTime getLastModifiedAt() { 323 return this.lastModifiedAt; 324 } 325 326 /** 327 * <p>Present on resources created after 1 February 2019 except for events not tracked.</p> 328 * @return lastModifiedBy 329 */ 330 331 @Nullable 332 public com.commercetools.api.models.common.LastModifiedBy getLastModifiedBy() { 333 return this.lastModifiedBy; 334 } 335 336 /** 337 * <p>Present on resources created after 1 February 2019 except for events not tracked.</p> 338 * @return createdBy 339 */ 340 341 @Nullable 342 public com.commercetools.api.models.common.CreatedBy getCreatedBy() { 343 return this.createdBy; 344 } 345 346 /** 347 * <p>User-defined unique identifier of the Zone.</p> 348 * @return key 349 */ 350 351 @Nullable 352 public String getKey() { 353 return this.key; 354 } 355 356 /** 357 * <p>Name of the Zone.</p> 358 * @return name 359 */ 360 361 public String getName() { 362 return this.name; 363 } 364 365 /** 366 * <p>Description of the Zone.</p> 367 * @return description 368 */ 369 370 @Nullable 371 public String getDescription() { 372 return this.description; 373 } 374 375 /** 376 * <p>List of locations that belong to the Zone.</p> 377 * @return locations 378 */ 379 380 public java.util.List<com.commercetools.api.models.zone.Location> getLocations() { 381 return this.locations; 382 } 383 384 /** 385 * builds Zone with checking for non-null required values 386 * @return Zone 387 */ 388 public Zone build() { 389 Objects.requireNonNull(id, Zone.class + ": id is missing"); 390 Objects.requireNonNull(version, Zone.class + ": version is missing"); 391 Objects.requireNonNull(createdAt, Zone.class + ": createdAt is missing"); 392 Objects.requireNonNull(lastModifiedAt, Zone.class + ": lastModifiedAt is missing"); 393 Objects.requireNonNull(name, Zone.class + ": name is missing"); 394 Objects.requireNonNull(locations, Zone.class + ": locations is missing"); 395 return new ZoneImpl(id, version, createdAt, lastModifiedAt, lastModifiedBy, createdBy, key, name, description, 396 locations); 397 } 398 399 /** 400 * builds Zone without checking for non-null required values 401 * @return Zone 402 */ 403 public Zone buildUnchecked() { 404 return new ZoneImpl(id, version, createdAt, lastModifiedAt, lastModifiedBy, createdBy, key, name, description, 405 locations); 406 } 407 408 /** 409 * factory method for an instance of ZoneBuilder 410 * @return builder 411 */ 412 public static ZoneBuilder of() { 413 return new ZoneBuilder(); 414 } 415 416 /** 417 * create builder for Zone instance 418 * @param template instance with prefilled values for the builder 419 * @return builder 420 */ 421 public static ZoneBuilder of(final Zone template) { 422 ZoneBuilder builder = new ZoneBuilder(); 423 builder.id = template.getId(); 424 builder.version = template.getVersion(); 425 builder.createdAt = template.getCreatedAt(); 426 builder.lastModifiedAt = template.getLastModifiedAt(); 427 builder.lastModifiedBy = template.getLastModifiedBy(); 428 builder.createdBy = template.getCreatedBy(); 429 builder.key = template.getKey(); 430 builder.name = template.getName(); 431 builder.description = template.getDescription(); 432 builder.locations = template.getLocations(); 433 return builder; 434 } 435 436}