TransportUnitVO.java
/*
* Copyright 2005-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.openwms.wms.transport.api;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import org.openwms.wms.location.api.LocationVO;
import java.io.Serializable;
import java.time.ZonedDateTime;
import java.util.Date;
import java.util.Objects;
import static org.openwms.wms.api.TimeProvider.DATE_TIME_WITH_TIMEZONE;
/**
* A TransportUnitVO.
*
* @author Heiko Scherrer
*/
@JsonInclude(JsonInclude.Include.NON_EMPTY)
public class TransportUnitVO extends MinimalTransportUnitVO implements Serializable {
public static final String MEDIA_TYPE = "application/vnd.openwms.wms.transport-unit-v1+json";
/** The actual {@code Location}. */
@JsonProperty("actualLocation")
@NotNull(message = "{owms.wms.inv.tu.actualLocation}", groups = ValidationGroups.CreateTransportUnit.class)
private LocationVO actualLocation;
@JsonProperty("actualLocationDate")
private Date actualLocationDate;
/** The state of the TransportUnit. */
@JsonProperty("state")
private String state;
/** Where the TransportUnit is routed to. */
@JsonProperty("target")
private String target;
/** The name of the TransportUnit's type. */
@NotBlank(message = "{owms.wms.inv.tu.transportUnitType}", groups = ValidationGroups.CreateTransportUnit.class)
@JsonProperty("transportUnitType")
private String transportUnitType;
/** The current length. */
@JsonProperty("length")
private Integer length;
/** The current width. */
@JsonProperty("width")
private Integer width;
/** The current height. */
@JsonProperty("height")
private Integer height;
/** An optional assignment to a customer order. */
@JsonProperty("customerOrderId")
private String customerOrderId;
@JsonProperty("reconciledBy")
private String reconciledBy;
@JsonProperty("reconciledAt")
@JsonFormat(pattern = DATE_TIME_WITH_TIMEZONE)
private ZonedDateTime reconciledAt;
/*~-------------------- constructors --------------------*/
@JsonCreator
protected TransportUnitVO() {}
public TransportUnitVO(String transportUnitBK) {
Objects.requireNonNull(transportUnitBK);
super.transportUnitBK = transportUnitBK;
}
private TransportUnitVO(Builder builder) {
transportUnitBK = builder.transportUnitBK;
actualLocation = builder.actualLocation;
target = builder.target;
transportUnitType = builder.transportUnitType;
length = builder.length;
width = builder.width;
height = builder.height;
customerOrderId = builder.customerOrderId;
reconciledBy = builder.reconciledBy;
reconciledAt = builder.reconciledAt;
}
public static Builder builder() {
return new Builder();
}
/*~-------------------- methods --------------------*/
/**
* {@inheritDoc}
*
* All fields.
*/
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof TransportUnitVO that)) return false;
if (!super.equals(o)) return false;
return Objects.equals(actualLocation, that.actualLocation) && Objects.equals(actualLocationDate, that.actualLocationDate) && Objects.equals(state, that.state) && Objects.equals(target, that.target) && Objects.equals(transportUnitType, that.transportUnitType) && Objects.equals(length, that.length) && Objects.equals(width, that.width) && Objects.equals(height, that.height) && Objects.equals(customerOrderId, that.customerOrderId) && Objects.equals(reconciledBy, that.reconciledBy) && Objects.equals(reconciledAt, that.reconciledAt);
}
/**
* {@inheritDoc}
*
* All fields.
*/
@Override
public int hashCode() {
return Objects.hash(super.hashCode(), actualLocation, actualLocationDate, state, target, transportUnitType, length, width, height, customerOrderId, reconciledBy, reconciledAt);
}
/*~-------------------- accessors --------------------*/
public LocationVO getActualLocation() {
return actualLocation;
}
public void setActualLocation(LocationVO actualLocation) {
this.actualLocation = actualLocation;
}
public Date getActualLocationDate() {
return actualLocationDate;
}
public void setActualLocationDate(Date actualLocationDate) {
this.actualLocationDate = actualLocationDate;
}
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
public String getTarget() {
return target;
}
public void setTarget(String target) {
this.target = target;
}
public String getTransportUnitType() {
return transportUnitType;
}
public void setTransportUnitType(String transportUnitType) {
this.transportUnitType = transportUnitType;
}
public Integer getLength() {
return length;
}
public void setLength(Integer length) {
this.length = length;
}
public Integer getWidth() {
return width;
}
public void setWidth(Integer width) {
this.width = width;
}
public Integer getHeight() {
return height;
}
public void setHeight(Integer height) {
this.height = height;
}
public String getCustomerOrderId() {
return customerOrderId;
}
public void setCustomerOrderId(String customerOrderId) {
this.customerOrderId = customerOrderId;
}
public String getReconciledBy() {
return reconciledBy;
}
public void setReconciledBy(String reconciledBy) {
this.reconciledBy = reconciledBy;
}
public ZonedDateTime getReconciledAt() {
return reconciledAt;
}
public void setReconciledAt(ZonedDateTime reconciledAt) {
this.reconciledAt = reconciledAt;
}
/*~-------------------- Builder --------------------*/
public static final class Builder {
private String transportUnitBK;
private LocationVO actualLocation;
private String target;
private String transportUnitType;
private Integer length;
private Integer width;
private Integer height;
private String customerOrderId;
private String reconciledBy;
private ZonedDateTime reconciledAt;
private Builder() {
}
public Builder transportUnitBK(String val) {
transportUnitBK = val;
return this;
}
public Builder actualLocation(LocationVO val) {
actualLocation = val;
return this;
}
public Builder target(String val) {
target = val;
return this;
}
public Builder transportUnitType(String val) {
transportUnitType = val;
return this;
}
public Builder length(Integer val) {
length = val;
return this;
}
public Builder width(Integer val) {
width = val;
return this;
}
public Builder height(Integer val) {
height = val;
return this;
}
public Builder customerOrderId(String val) {
customerOrderId = val;
return this;
}
public Builder reconciledBy(String val) {
reconciledBy = val;
return this;
}
public Builder reconciledAt(ZonedDateTime val) {
reconciledAt = val;
return this;
}
public TransportUnitVO build() {
return new TransportUnitVO(this);
}
}
}