com.commercetools.history.models.change_value.DeliveryChangeValueBuilder Maven / Gradle / Ivy
Show all versions of commercetools-sdk-java-history Show documentation
package com.commercetools.history.models.change_value;
import java.util.*;
import java.util.function.Function;
import io.vrap.rmf.base.client.Builder;
import io.vrap.rmf.base.client.utils.Generated;
/**
* DeliveryChangeValueBuilder
*
* Example to create an instance using the builder pattern
*
*
* DeliveryChangeValue deliveryChangeValue = DeliveryChangeValue.builder()
* .plusItems(itemsBuilder -> itemsBuilder)
* .address(addressBuilder -> addressBuilder)
* .plusParcels(parcelsBuilder -> parcelsBuilder)
* .build()
*
*
*/
@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen")
public class DeliveryChangeValueBuilder implements Builder {
private java.util.List items;
private com.commercetools.history.models.common.Address address;
private java.util.List parcels;
/**
* Line Items or Custom Line Items shipped in the Delivery.
* @param items value to be set
* @return Builder
*/
public DeliveryChangeValueBuilder items(final com.commercetools.history.models.common.DeliveryItem... items) {
this.items = new ArrayList<>(Arrays.asList(items));
return this;
}
/**
* Line Items or Custom Line Items shipped in the Delivery.
* @param items value to be set
* @return Builder
*/
public DeliveryChangeValueBuilder items(
final java.util.List items) {
this.items = items;
return this;
}
/**
* Line Items or Custom Line Items shipped in the Delivery.
* @param items value to be set
* @return Builder
*/
public DeliveryChangeValueBuilder 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;
}
/**
* Line Items or Custom Line Items shipped in the Delivery.
* @param builder function to build the items value
* @return Builder
*/
public DeliveryChangeValueBuilder 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;
}
/**
* Line Items or Custom Line Items shipped in the Delivery.
* @param builder function to build the items value
* @return Builder
*/
public DeliveryChangeValueBuilder withItems(
Function builder) {
this.items = new ArrayList<>();
this.items.add(builder.apply(com.commercetools.history.models.common.DeliveryItemBuilder.of()).build());
return this;
}
/**
* Line Items or Custom Line Items shipped in the Delivery.
* @param builder function to build the items value
* @return Builder
*/
public DeliveryChangeValueBuilder addItems(
Function builder) {
return plusItems(builder.apply(com.commercetools.history.models.common.DeliveryItemBuilder.of()));
}
/**
* Line Items or Custom Line Items shipped in the Delivery.
* @param builder function to build the items value
* @return Builder
*/
public DeliveryChangeValueBuilder setItems(
Function builder) {
return items(builder.apply(com.commercetools.history.models.common.DeliveryItemBuilder.of()));
}
/**
* Address to which the parcels are delivered.
* @param builder function to build the address value
* @return Builder
*/
public DeliveryChangeValueBuilder address(
Function builder) {
this.address = builder.apply(com.commercetools.history.models.common.AddressBuilder.of()).build();
return this;
}
/**
* Address to which the parcels are delivered.
* @param builder function to build the address value
* @return Builder
*/
public DeliveryChangeValueBuilder withAddress(
Function builder) {
this.address = builder.apply(com.commercetools.history.models.common.AddressBuilder.of());
return this;
}
/**
* Address to which the parcels are delivered.
* @param address value to be set
* @return Builder
*/
public DeliveryChangeValueBuilder address(final com.commercetools.history.models.common.Address address) {
this.address = address;
return this;
}
/**
* Parcels included in the Delivery.
* @param parcels value to be set
* @return Builder
*/
public DeliveryChangeValueBuilder parcels(final com.commercetools.history.models.common.Parcel... parcels) {
this.parcels = new ArrayList<>(Arrays.asList(parcels));
return this;
}
/**
* Parcels included in the Delivery.
* @param parcels value to be set
* @return Builder
*/
public DeliveryChangeValueBuilder parcels(
final java.util.List parcels) {
this.parcels = parcels;
return this;
}
/**
* Parcels included in the Delivery.
* @param parcels value to be set
* @return Builder
*/
public DeliveryChangeValueBuilder 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;
}
/**
* Parcels included in the Delivery.
* @param builder function to build the parcels value
* @return Builder
*/
public DeliveryChangeValueBuilder 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;
}
/**
* Parcels included in the Delivery.
* @param builder function to build the parcels value
* @return Builder
*/
public DeliveryChangeValueBuilder withParcels(
Function builder) {
this.parcels = new ArrayList<>();
this.parcels.add(builder.apply(com.commercetools.history.models.common.ParcelBuilder.of()).build());
return this;
}
/**
* Parcels included in the Delivery.
* @param builder function to build the parcels value
* @return Builder
*/
public DeliveryChangeValueBuilder addParcels(
Function builder) {
return plusParcels(builder.apply(com.commercetools.history.models.common.ParcelBuilder.of()));
}
/**
* Parcels included in the Delivery.
* @param builder function to build the parcels value
* @return Builder
*/
public DeliveryChangeValueBuilder setParcels(
Function builder) {
return parcels(builder.apply(com.commercetools.history.models.common.ParcelBuilder.of()));
}
/**
* Line Items or Custom Line Items shipped in the Delivery.
* @return items
*/
public java.util.List getItems() {
return this.items;
}
/**
* Address to which the parcels are delivered.
* @return address
*/
public com.commercetools.history.models.common.Address getAddress() {
return this.address;
}
/**
* Parcels included in the Delivery.
* @return parcels
*/
public java.util.List getParcels() {
return this.parcels;
}
/**
* builds DeliveryChangeValue with checking for non-null required values
* @return DeliveryChangeValue
*/
public DeliveryChangeValue build() {
Objects.requireNonNull(items, DeliveryChangeValue.class + ": items is missing");
Objects.requireNonNull(address, DeliveryChangeValue.class + ": address is missing");
Objects.requireNonNull(parcels, DeliveryChangeValue.class + ": parcels is missing");
return new DeliveryChangeValueImpl(items, address, parcels);
}
/**
* builds DeliveryChangeValue without checking for non-null required values
* @return DeliveryChangeValue
*/
public DeliveryChangeValue buildUnchecked() {
return new DeliveryChangeValueImpl(items, address, parcels);
}
/**
* factory method for an instance of DeliveryChangeValueBuilder
* @return builder
*/
public static DeliveryChangeValueBuilder of() {
return new DeliveryChangeValueBuilder();
}
/**
* create builder for DeliveryChangeValue instance
* @param template instance with prefilled values for the builder
* @return builder
*/
public static DeliveryChangeValueBuilder of(final DeliveryChangeValue template) {
DeliveryChangeValueBuilder builder = new DeliveryChangeValueBuilder();
builder.items = template.getItems();
builder.address = template.getAddress();
builder.parcels = template.getParcels();
return builder;
}
}