LoadUnitVO.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.inventory.api;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.ameba.http.AbstractBase;

import java.util.Objects;

/**
 * A LoadUnitVO.
 *
 * @author Heiko Scherrer
 */
@JsonInclude(JsonInclude.Include.NON_EMPTY)
public class LoadUnitVO extends AbstractBase<LoadUnitVO> {

    /** The persistent key of the {@code LoadUnit}. */
    @JsonProperty("pKey")
    public String pKey;
    /** The business key of the {@code TransportUnit}. */
    @JsonProperty("transportUnitBK")
    public String transportUnitBK;
    /** The position this {@code LoadUnit} is located on the {@code TransportUnit}. */
    @JsonProperty("physicalPosition")
    public String physicalPosition;
    /** An identifying label of the {@code LoadUnit}. */
    @JsonProperty("label")
    public String label;
    /** The type of the {@code LoadUnit}. */
    @JsonProperty("type")
    public String type;
    /** Locked for allocation. */
    @JsonProperty("locked")
    public Boolean locked = Boolean.FALSE;
    /** The {@code Product} that is carried within the {@code LoadUnit}. */
    @JsonProperty("product")
    public ProductVO product;
    /** The current dimension of the {@code LoadUnit}. */
    @JsonProperty("dimension")
    public DimensionVO dimension;

    /*~ -------------- Constructors --------------- */
    @JsonCreator
    public LoadUnitVO() {}

    public LoadUnitVO(String pKey) {
        this.pKey = pKey;
    }

    public LoadUnitVO(String transportUnitBK, String physicalPosition) {
        this.transportUnitBK = transportUnitBK;
        this.physicalPosition = physicalPosition;
    }

    /*~ --------------- Accessors ---------------- */
    public String getpKey() {
        return pKey;
    }

    public void setpKey(String pKey) {
        this.pKey = pKey;
    }

    public String getTransportUnitBK() {
        return transportUnitBK;
    }

    public void setTransportUnitBK(String transportUnitBK) {
        this.transportUnitBK = transportUnitBK;
    }

    public String getPhysicalPosition() {
        return physicalPosition;
    }

    public void setPhysicalPosition(String physicalPosition) {
        this.physicalPosition = physicalPosition;
    }

    public String getLabel() {
        return label;
    }

    public void setLabel(String label) {
        this.label = label;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public Boolean getLocked() {
        return locked;
    }

    public void setLocked(Boolean locked) {
        this.locked = locked;
    }

    public ProductVO getProduct() {
        return product;
    }

    public void setProduct(ProductVO product) {
        this.product = product;
    }

    public DimensionVO getDimension() {
        return dimension;
    }

    public void setDimension(DimensionVO dimension) {
        this.dimension = dimension;
    }

    /*~ --------------- Methods ---------------- */
    @Override
    public String toString() {
        return transportUnitBK + '\'' +
                physicalPosition + '\'' +
                label;
    }

    /**
     * {@inheritDoc}
     *
     * All fields.
     */
    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        if (!super.equals(o)) return false;
        LoadUnitVO that = (LoadUnitVO) o;
        return locked == that.locked && Objects.equals(pKey, that.pKey) && Objects.equals(transportUnitBK, that.transportUnitBK) && Objects.equals(physicalPosition, that.physicalPosition) && Objects.equals(label, that.label) && Objects.equals(type, that.type) && Objects.equals(product, that.product) && Objects.equals(dimension, that.dimension);
    }

    /**
     * {@inheritDoc}
     *
     * All fields.
     */
    @Override
    public int hashCode() {
        return Objects.hash(super.hashCode(), pKey, transportUnitBK, physicalPosition, label, type, locked, product, dimension);
    }
}