com.commercetools.history.models.common.ParcelBuilder 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 io.vrap.rmf.base.client.Builder;
import io.vrap.rmf.base.client.utils.Generated;
/**
* ParcelBuilder
*
* Example to create an instance using the builder pattern
*
*
* Parcel parcel = Parcel.builder()
* .id("{id}")
* .createdAt("{createdAt}")
* .measurements(measurementsBuilder -> measurementsBuilder)
* .trackingData(trackingDataBuilder -> trackingDataBuilder)
* .plusItems(itemsBuilder -> itemsBuilder)
* .build()
*
*
*/
@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen")
public class ParcelBuilder implements Builder {
private String id;
private String createdAt;
private com.commercetools.history.models.common.ParcelMeasurements measurements;
private com.commercetools.history.models.common.TrackingData trackingData;
private java.util.List items;
/**
* set the value to the id
* @param id value to be set
* @return Builder
*/
public ParcelBuilder id(final String id) {
this.id = id;
return this;
}
/**
* set the value to the createdAt
* @param createdAt value to be set
* @return Builder
*/
public ParcelBuilder createdAt(final String createdAt) {
this.createdAt = createdAt;
return this;
}
/**
* set the value to the measurements using the builder function
* @param builder function to build the measurements value
* @return Builder
*/
public ParcelBuilder measurements(
Function builder) {
this.measurements = builder.apply(com.commercetools.history.models.common.ParcelMeasurementsBuilder.of())
.build();
return this;
}
/**
* set the value to the measurements using the builder function
* @param builder function to build the measurements value
* @return Builder
*/
public ParcelBuilder withMeasurements(
Function builder) {
this.measurements = builder.apply(com.commercetools.history.models.common.ParcelMeasurementsBuilder.of());
return this;
}
/**
* set the value to the measurements
* @param measurements value to be set
* @return Builder
*/
public ParcelBuilder measurements(final com.commercetools.history.models.common.ParcelMeasurements measurements) {
this.measurements = measurements;
return this;
}
/**
* set the value to the trackingData using the builder function
* @param builder function to build the trackingData value
* @return Builder
*/
public ParcelBuilder trackingData(
Function builder) {
this.trackingData = builder.apply(com.commercetools.history.models.common.TrackingDataBuilder.of()).build();
return this;
}
/**
* set the value to the trackingData using the builder function
* @param builder function to build the trackingData value
* @return Builder
*/
public ParcelBuilder withTrackingData(
Function builder) {
this.trackingData = builder.apply(com.commercetools.history.models.common.TrackingDataBuilder.of());
return this;
}
/**
* set the value to the trackingData
* @param trackingData value to be set
* @return Builder
*/
public ParcelBuilder trackingData(final com.commercetools.history.models.common.TrackingData trackingData) {
this.trackingData = trackingData;
return this;
}
/**
* set values to the items
* @param items value to be set
* @return Builder
*/
public ParcelBuilder 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 ParcelBuilder 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 ParcelBuilder 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 ParcelBuilder 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 ParcelBuilder 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 ParcelBuilder 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 ParcelBuilder setItems(
Function builder) {
return items(builder.apply(com.commercetools.history.models.common.DeliveryItemBuilder.of()));
}
/**
* value of id}
* @return id
*/
public String getId() {
return this.id;
}
/**
* value of createdAt}
* @return createdAt
*/
public String getCreatedAt() {
return this.createdAt;
}
/**
* value of measurements}
* @return measurements
*/
public com.commercetools.history.models.common.ParcelMeasurements getMeasurements() {
return this.measurements;
}
/**
* value of trackingData}
* @return trackingData
*/
public com.commercetools.history.models.common.TrackingData getTrackingData() {
return this.trackingData;
}
/**
* value of items}
* @return items
*/
public java.util.List getItems() {
return this.items;
}
/**
* builds Parcel with checking for non-null required values
* @return Parcel
*/
public Parcel build() {
Objects.requireNonNull(id, Parcel.class + ": id is missing");
Objects.requireNonNull(createdAt, Parcel.class + ": createdAt is missing");
Objects.requireNonNull(measurements, Parcel.class + ": measurements is missing");
Objects.requireNonNull(trackingData, Parcel.class + ": trackingData is missing");
Objects.requireNonNull(items, Parcel.class + ": items is missing");
return new ParcelImpl(id, createdAt, measurements, trackingData, items);
}
/**
* builds Parcel without checking for non-null required values
* @return Parcel
*/
public Parcel buildUnchecked() {
return new ParcelImpl(id, createdAt, measurements, trackingData, items);
}
/**
* factory method for an instance of ParcelBuilder
* @return builder
*/
public static ParcelBuilder of() {
return new ParcelBuilder();
}
/**
* create builder for Parcel instance
* @param template instance with prefilled values for the builder
* @return builder
*/
public static ParcelBuilder of(final Parcel template) {
ParcelBuilder builder = new ParcelBuilder();
builder.id = template.getId();
builder.createdAt = template.getCreatedAt();
builder.measurements = template.getMeasurements();
builder.trackingData = template.getTrackingData();
builder.items = template.getItems();
return builder;
}
}