PackagingUnitMO.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.events;

import jakarta.validation.constraints.NotNull;
import org.openwms.core.units.api.Measurable;
import org.openwms.wms.inventory.PackagingUnit;

import java.io.Serializable;
import java.util.Objects;

/**
 * A PackagingUnitMO is a message object that represents a {@code PackagingUnit}.
 *
 * @author Heiko Scherrer
 */
public class PackagingUnitMO implements Serializable {

    /** The persistent key of the PackagingUnit. */
    private String pKey;
    /** Some hint where to find the {@link PackagingUnit} within its container. */
    private String physicalPosition;
    /** The serial number PackagingUnit. */
    private String serialNumber;
    /** Packed Product, must not be {@literal null}. */
    @NotNull
    private ProductMO product;
    /** Packed quantity, must not be {@literal null}. */
    @NotNull
    private Measurable quantity;
    /** The actualLocation the PackagingUnit is placed on. */
    private String actualLocation;

    public String getpKey() {
        return pKey;
    }

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

    public String getPhysicalPosition() {
        return physicalPosition;
    }

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

    public String getSerialNumber() {
        return serialNumber;
    }

    public void setSerialNumber(String serialNumber) {
        this.serialNumber = serialNumber;
    }

    public ProductMO getProduct() {
        return product;
    }

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

    public Measurable getQuantity() {
        return quantity;
    }

    public void setQuantity(Measurable quantity) {
        this.quantity = quantity;
    }

    public String getActualLocation() {
        return actualLocation;
    }

    public void setActualLocation(String actualLocation) {
        this.actualLocation = actualLocation;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof PackagingUnitMO)) return false;
        PackagingUnitMO that = (PackagingUnitMO) o;
        return Objects.equals(pKey, that.pKey) && Objects.equals(physicalPosition, that.physicalPosition) && Objects.equals(serialNumber, that.serialNumber) && Objects.equals(product, that.product) && Objects.equals(quantity, that.quantity) && Objects.equals(actualLocation, that.actualLocation);
    }

    @Override
    public int hashCode() {
        return Objects.hash(pKey, physicalPosition, serialNumber, product, quantity, actualLocation);
    }

    @Override
    public String toString() {
        return "PackagingUnitMO{" +
                "pKey='" + pKey + '\'' +
                ", physicalPosition='" + physicalPosition + '\'' +
                ", serialNumber='" + serialNumber + '\'' +
                ", product=" + product +
                ", quantity=" + quantity +
                ", actualLocation='" + actualLocation + '\'' +
                '}';
    }
}