com.commercetools.history.models.common.DeliveryBuilder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of commercetools-sdk-java-history Show documentation
Show all versions of commercetools-sdk-java-history Show documentation
The e-commerce SDK from commercetools Composable Commerce for Java
package com.commercetools.history.models.common;
import java.util.*;
import java.util.function.Function;
import javax.annotation.Nullable;
import io.vrap.rmf.base.client.Builder;
import io.vrap.rmf.base.client.utils.Generated;
/**
* DeliveryBuilder
*
* Example to create an instance using the builder pattern
*
*
* Delivery delivery = Delivery.builder()
* .id("{id}")
* .createdAt("{createdAt}")
* .plusItems(itemsBuilder -> itemsBuilder)
* .plusParcels(parcelsBuilder -> parcelsBuilder)
* .build()
*
*
*/
@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen")
public class DeliveryBuilder implements Builder {
private String id;
private String createdAt;
private java.util.List items;
private java.util.List parcels;
@Nullable
private com.commercetools.history.models.common.Address address;
@Nullable
private com.commercetools.history.models.common.CustomFields custom;
/**
* set the value to the id
* @param id value to be set
* @return Builder
*/
public DeliveryBuilder id(final String id) {
this.id = id;
return this;
}
/**
* set the value to the createdAt
* @param createdAt value to be set
* @return Builder
*/
public DeliveryBuilder createdAt(final String createdAt) {
this.createdAt = createdAt;
return this;
}
/**
* set values to the items
* @param items value to be set
* @return Builder
*/
public DeliveryBuilder items(final com.commercetools.history.models.common.DeliveryItem... items) {
this.items = new ArrayList<>(Arrays.asList(items));
return this;
}
/**
* set value to the items
* @param items value to be set
* @return Builder
*/
public DeliveryBuilder items(final java.util.List items) {
this.items = items;
return this;
}
/**
* add values to the items
* @param items value to be set
* @return Builder
*/
public DeliveryBuilder plusItems(final com.commercetools.history.models.common.DeliveryItem... items) {
if (this.items == null) {
this.items = new ArrayList<>();
}
this.items.addAll(Arrays.asList(items));
return this;
}
/**
* add the value to the items using the builder function
* @param builder function to build the items value
* @return Builder
*/
public DeliveryBuilder plusItems(
Function builder) {
if (this.items == null) {
this.items = new ArrayList<>();
}
this.items.add(builder.apply(com.commercetools.history.models.common.DeliveryItemBuilder.of()).build());
return this;
}
/**
* set the value to the items using the builder function
* @param builder function to build the items value
* @return Builder
*/
public DeliveryBuilder withItems(
Function builder) {
this.items = new ArrayList<>();
this.items.add(builder.apply(com.commercetools.history.models.common.DeliveryItemBuilder.of()).build());
return this;
}
/**
* add the value to the items using the builder function
* @param builder function to build the items value
* @return Builder
*/
public DeliveryBuilder addItems(
Function builder) {
return plusItems(builder.apply(com.commercetools.history.models.common.DeliveryItemBuilder.of()));
}
/**
* set the value to the items using the builder function
* @param builder function to build the items value
* @return Builder
*/
public DeliveryBuilder setItems(
Function builder) {
return items(builder.apply(com.commercetools.history.models.common.DeliveryItemBuilder.of()));
}
/**
* set values to the parcels
* @param parcels value to be set
* @return Builder
*/
public DeliveryBuilder parcels(final com.commercetools.history.models.common.Parcel... parcels) {
this.parcels = new ArrayList<>(Arrays.asList(parcels));
return this;
}
/**
* set value to the parcels
* @param parcels value to be set
* @return Builder
*/
public DeliveryBuilder parcels(final java.util.List parcels) {
this.parcels = parcels;
return this;
}
/**
* add values to the parcels
* @param parcels value to be set
* @return Builder
*/
public DeliveryBuilder plusParcels(final com.commercetools.history.models.common.Parcel... parcels) {
if (this.parcels == null) {
this.parcels = new ArrayList<>();
}
this.parcels.addAll(Arrays.asList(parcels));
return this;
}
/**
* add the value to the parcels using the builder function
* @param builder function to build the parcels value
* @return Builder
*/
public DeliveryBuilder plusParcels(
Function builder) {
if (this.parcels == null) {
this.parcels = new ArrayList<>();
}
this.parcels.add(builder.apply(com.commercetools.history.models.common.ParcelBuilder.of()).build());
return this;
}
/**
* set the value to the parcels using the builder function
* @param builder function to build the parcels value
* @return Builder
*/
public DeliveryBuilder withParcels(
Function builder) {
this.parcels = new ArrayList<>();
this.parcels.add(builder.apply(com.commercetools.history.models.common.ParcelBuilder.of()).build());
return this;
}
/**
* add the value to the parcels using the builder function
* @param builder function to build the parcels value
* @return Builder
*/
public DeliveryBuilder addParcels(
Function builder) {
return plusParcels(builder.apply(com.commercetools.history.models.common.ParcelBuilder.of()));
}
/**
* set the value to the parcels using the builder function
* @param builder function to build the parcels value
* @return Builder
*/
public DeliveryBuilder setParcels(
Function builder) {
return parcels(builder.apply(com.commercetools.history.models.common.ParcelBuilder.of()));
}
/**
* set the value to the address using the builder function
* @param builder function to build the address value
* @return Builder
*/
public DeliveryBuilder address(
Function builder) {
this.address = builder.apply(com.commercetools.history.models.common.AddressBuilder.of()).build();
return this;
}
/**
* set the value to the address using the builder function
* @param builder function to build the address value
* @return Builder
*/
public DeliveryBuilder withAddress(
Function builder) {
this.address = builder.apply(com.commercetools.history.models.common.AddressBuilder.of());
return this;
}
/**
* set the value to the address
* @param address value to be set
* @return Builder
*/
public DeliveryBuilder address(@Nullable final com.commercetools.history.models.common.Address address) {
this.address = address;
return this;
}
/**
* Custom Fields for the Transaction.
* @param builder function to build the custom value
* @return Builder
*/
public DeliveryBuilder custom(
Function builder) {
this.custom = builder.apply(com.commercetools.history.models.common.CustomFieldsBuilder.of()).build();
return this;
}
/**
* Custom Fields for the Transaction.
* @param builder function to build the custom value
* @return Builder
*/
public DeliveryBuilder withCustom(
Function builder) {
this.custom = builder.apply(com.commercetools.history.models.common.CustomFieldsBuilder.of());
return this;
}
/**
* Custom Fields for the Transaction.
* @param custom value to be set
* @return Builder
*/
public DeliveryBuilder custom(@Nullable final com.commercetools.history.models.common.CustomFields custom) {
this.custom = custom;
return this;
}
/**
* value of id}
* @return id
*/
public String getId() {
return this.id;
}
/**
* value of createdAt}
* @return createdAt
*/
public String getCreatedAt() {
return this.createdAt;
}
/**
* value of items}
* @return items
*/
public java.util.List getItems() {
return this.items;
}
/**
* value of parcels}
* @return parcels
*/
public java.util.List getParcels() {
return this.parcels;
}
/**
* value of address}
* @return address
*/
@Nullable
public com.commercetools.history.models.common.Address getAddress() {
return this.address;
}
/**
* Custom Fields for the Transaction.
* @return custom
*/
@Nullable
public com.commercetools.history.models.common.CustomFields getCustom() {
return this.custom;
}
/**
* builds Delivery with checking for non-null required values
* @return Delivery
*/
public Delivery build() {
Objects.requireNonNull(id, Delivery.class + ": id is missing");
Objects.requireNonNull(createdAt, Delivery.class + ": createdAt is missing");
Objects.requireNonNull(items, Delivery.class + ": items is missing");
Objects.requireNonNull(parcels, Delivery.class + ": parcels is missing");
return new DeliveryImpl(id, createdAt, items, parcels, address, custom);
}
/**
* builds Delivery without checking for non-null required values
* @return Delivery
*/
public Delivery buildUnchecked() {
return new DeliveryImpl(id, createdAt, items, parcels, address, custom);
}
/**
* factory method for an instance of DeliveryBuilder
* @return builder
*/
public static DeliveryBuilder of() {
return new DeliveryBuilder();
}
/**
* create builder for Delivery instance
* @param template instance with prefilled values for the builder
* @return builder
*/
public static DeliveryBuilder of(final Delivery template) {
DeliveryBuilder builder = new DeliveryBuilder();
builder.id = template.getId();
builder.createdAt = template.getCreatedAt();
builder.items = template.getItems();
builder.parcels = template.getParcels();
builder.address = template.getAddress();
builder.custom = template.getCustom();
return builder;
}
}