ReportProblemVO.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.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import jakarta.validation.constraints.NotNull;
import org.ameba.http.AbstractBase;
import org.openwms.core.units.api.Measurable;

import java.util.Objects;

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

    /** A message number that identifies the problem. */
    @JsonProperty("messageNo")
    private Integer messageNo;
    /** The reported amount of PackagingUnits with that problem. */
    @JsonProperty("numberOfPackagingUnits")
    private Integer numberOfPackagingUnits;
    /** The {@code Product} that has the problem. */
    @JsonProperty("product")
    public ProductVO product;
    /** The quantity of the PackagingUnit in case multiple PackagingUnits with different quantities exist in the LoadUnit. */
    @JsonProperty("quantity")
    @NotNull
    private Measurable quantity;

    public Integer getMessageNo() {
        return messageNo;
    }

    public void setMessageNo(Integer messageNo) {
        this.messageNo = messageNo;
    }

    public Integer getNumberOfPackagingUnits() {
        return numberOfPackagingUnits;
    }

    public void setNumberOfPackagingUnits(Integer numberOfPackagingUnits) {
        this.numberOfPackagingUnits = numberOfPackagingUnits;
    }

    public ProductVO getProduct() {
        return product;
    }

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

    public Measurable getQuantity() {
        return quantity;
    }

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

    /**
     * {@inheritDoc}
     *
     * All fields.
     */
    @Override
    public String toString() {
        return "ReportProblemVO{" +
                "messageNo=" + messageNo +
                ", numberOfPackagingUnits=" + numberOfPackagingUnits +
                ", product=" + product +
                ", quantity=" + quantity +
                '}';
    }

    /**
     * {@inheritDoc}
     *
     * All fields.
     */
    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof ReportProblemVO)) return false;
        if (!super.equals(o)) return false;
        ReportProblemVO that = (ReportProblemVO) o;
        return Objects.equals(messageNo, that.messageNo) && Objects.equals(numberOfPackagingUnits, that.numberOfPackagingUnits) && Objects.equals(product, that.product) && Objects.equals(quantity, that.quantity);
    }

    /**
     * {@inheritDoc}
     *
     * All fields.
     */
    @Override
    public int hashCode() {
        return Objects.hash(super.hashCode(), messageNo, numberOfPackagingUnits, product, quantity);
    }
}