com.logicommerce.sdk.builders.order.OrderBaseStatusBuilder 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.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import com.logicommerce.sdk.models.order.OrderBaseStatus;
import com.logicommerce.sdk.models.order.implementations.OrderBaseStatusImpl;
/**
* Abstract OrderBaseStatusBuilder class.
*
* @author Logicommerce
* @since 1.0.16
*/
public abstract class OrderBaseStatusBuilder {
private P parentBuilder;
protected List>> actions;
protected LocalDateTime currentDateTime;
protected Integer id;
protected T status;
protected int substatusId;
/**
* Constructor for OrderBaseStatusBuilder.
*/
protected OrderBaseStatusBuilder() {
id = null;
actions = new ArrayList<>();
currentDateTime = LocalDateTime.now();
substatusId = 0;
}
/**
* Constructor for OrderBaseStatusBuilder.
*
* @param parentBuilder a P object
*/
protected OrderBaseStatusBuilder(P parentBuilder) {
this();
this.parentBuilder = parentBuilder;
}
/**
* id.
*
* @param id a {@link java.lang.Integer} object
* @return a {@link com.logicommerce.sdk.builders.order.OrderBaseStatusBuilder} object
*/
public OrderBaseStatusBuilder id(Integer id) {
this.id = id;
return this;
}
/**
* actions.
*
* @return a {@link com.logicommerce.sdk.builders.order.OrderStatusActionBuilder} object
*/
public OrderStatusActionBuilder> actions() {
OrderStatusActionBuilder> action = new OrderStatusActionBuilder<>(this);
actions.add(action);
return action;
}
/**
* currentDateTime.
*
* @param currentDateTime a {@link java.time.LocalDateTime} object
* @return a {@link com.logicommerce.sdk.builders.order.OrderBaseStatusBuilder} object
*/
public OrderBaseStatusBuilder currentDateTime(LocalDateTime currentDateTime) {
this.currentDateTime = currentDateTime;
return this;
}
/**
* status.
*
* @param status a T object
* @return a {@link com.logicommerce.sdk.builders.order.OrderBaseStatusBuilder} object
*/
public OrderBaseStatusBuilder status(T status) {
this.status = status;
return this;
}
/**
* substatusId.
*
* @param substatusId a int
* @return a {@link com.logicommerce.sdk.builders.order.OrderBaseStatusBuilder} object
*/
public OrderBaseStatusBuilder substatusId(int substatusId) {
this.substatusId = substatusId;
return this;
}
/**
* setFields.
*
* @param statusLine a {@link com.logicommerce.sdk.models.order.implementations.OrderBaseStatusImpl} object
*/
protected void setFields(OrderBaseStatusImpl statusLine) {
statusLine.setId(null);
statusLine.setActions(actions.stream().map(OrderStatusActionBuilder::build).collect(Collectors.toList()));
statusLine.setCurrentDateTime(currentDateTime);
statusLine.setStatus(status);
statusLine.setSubstatusId(substatusId);
}
/**
* build.
*
* @return a {@link com.logicommerce.sdk.models.order.OrderBaseStatus} object
*/
public abstract OrderBaseStatus build();
/**
* done.
*
* @return a P object
*/
public P done() {
return parentBuilder;
}
}