com.logicommerce.sdk.builders.order.OrderDeliveryBuilder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sdk Show documentation
Show all versions of sdk Show documentation
SDK for developing Logicommerce plugins.
package com.logicommerce.sdk.builders.order;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import com.logicommerce.sdk.builders.GeographicalZoneBuilder;
import com.logicommerce.sdk.enums.DeliveryType;
import com.logicommerce.sdk.models.order.OrderDelivery;
import com.logicommerce.sdk.models.order.implementations.OrderDeliveryImpl;
/**
* OrderDeliveryBuilder class.
*
* @author Logicommerce
* @since 1.0.16
*/
public class OrderDeliveryBuilder {
private T parentBuilder;
private DeliveryType type;
private OrderDeliveryPhysicalLocationBuilder> physicalLocation;
private List>> shipments;
private GeographicalZoneBuilder> geographicalZone;
private ProviderPickupPointPickingDocumentDeliveryBuilder> providerPickupPointPickingDocumentDelivery;
/**
* Constructor for OrderDeliveryBuilder.
*/
public OrderDeliveryBuilder() {
geographicalZone = new GeographicalZoneBuilder<>(this);
shipments = new ArrayList<>();
physicalLocation = new OrderDeliveryPhysicalLocationBuilder<>(this);
type = DeliveryType.SHIPPING;
providerPickupPointPickingDocumentDelivery = new ProviderPickupPointPickingDocumentDeliveryBuilder<>(this);
}
/**
* Constructor for OrderDeliveryBuilder.
*
* @param parentBuilder a T object
*/
public OrderDeliveryBuilder(T parentBuilder) {
this();
this.parentBuilder = parentBuilder;
}
/**
* type.
*
* @param type a {@link com.logicommerce.sdk.enums.DeliveryType} object
* @return a {@link com.logicommerce.sdk.builders.order.OrderDeliveryBuilder} object
*/
public OrderDeliveryBuilder type(DeliveryType type) {
this.type = type;
return this;
}
/**
* geographicalZone.
*
* @return a {@link com.logicommerce.sdk.builders.GeographicalZoneBuilder} object
*/
public GeographicalZoneBuilder> geographicalZone() {
return this.geographicalZone;
}
/**
* physicalLocation.
*
* @return a {@link com.logicommerce.sdk.builders.order.OrderDeliveryPhysicalLocationBuilder} object
*/
public OrderDeliveryPhysicalLocationBuilder> physicalLocation() {
return this.physicalLocation;
}
/**
* shipments.
*
* @return a {@link com.logicommerce.sdk.builders.order.OrderShipmentBuilder} object
*/
public OrderShipmentBuilder> shipments() {
OrderShipmentBuilder> shipment = new OrderShipmentBuilder<>(this);
shipments.add(shipment);
return shipment;
}
/**
* providerPickupPointPickingDocumentDelivery.
*
* @return a {@link com.logicommerce.sdk.builders.order.ProviderPickupPointPickingDocumentDeliveryBuilder} object
*/
public ProviderPickupPointPickingDocumentDeliveryBuilder> providerPickupPointPickingDocumentDelivery() {
return this.providerPickupPointPickingDocumentDelivery;
}
/**
* build.
*
* @return a {@link com.logicommerce.sdk.models.order.OrderDelivery} object
*/
public OrderDelivery build() {
OrderDeliveryImpl delivery = new OrderDeliveryImpl();
delivery.setGeographicalZone(geographicalZone.build());
delivery.setPhysicalLocation(physicalLocation.build());
delivery.setShipments(shipments.stream().map(OrderShipmentBuilder::build).collect(Collectors.toList()));
delivery.setType(type);
delivery.setProviderPickupPointPickingDocumentDelivery(providerPickupPointPickingDocumentDelivery.build());
return delivery;
}
/**
* done.
*
* @return a T object
*/
public T done() {
return parentBuilder;
}
}