package jnpf.attendance.schedule;

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

/**
 * 排班班次块内的单岗位需求：工种（岗位）id + 人数。
 */
public final class ShiftPlanPostNeed implements Serializable {

    private final String postId;
    private final int needCount;

    public ShiftPlanPostNeed(String postId, int needCount) {
        this.postId = postId == null ? "" : postId;
        this.needCount = Math.max(0, needCount);
    }

    public String getPostId() {
        return postId;
    }

    public int getNeedCount() {
        return needCount;
    }

    @Override
    public String toString() {
        return postId + "=" + needCount;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        ShiftPlanPostNeed that = (ShiftPlanPostNeed) o;
        return needCount == that.needCount && postId.equals(that.postId);
    }

    @Override
    public int hashCode() {
        return Objects.hash(postId, needCount);
    }
}
