package com.sonymusic.dx.persistence.gras;

import jakarta.persistence.Column;
import jakarta.persistence.Embeddable;

import java.io.Serializable;

@Embeddable
public class RepOwnerTerritorySplitDealPk implements Serializable {

    private static final long serialVersionUID = 1L;

    @Column(name = "deal_no", nullable = false)
    private Long dealNo;

    @Column(name = "rep_owner_key", nullable = false, length = 250)
    private String repOwner;

    @Column(name = "dist_area_key", nullable = false, length = 250)
    private String territory;

    public RepOwnerTerritorySplitDealPk() {}

    public RepOwnerTerritorySplitDealPk(Long dealNo, String repOwner, String territory) {
        this.dealNo = dealNo;
        this.repOwner = repOwner;
        this.territory = territory;
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((dealNo == null) ? 0 : dealNo.hashCode());
        result = prime * result + ((repOwner == null) ? 0 : repOwner.hashCode());
        result = prime * result + ((territory == null) ? 0 : territory.hashCode());
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        RepOwnerTerritorySplitDealPk other = (RepOwnerTerritorySplitDealPk) obj;
        if (dealNo == null) {
            if (other.dealNo != null)
                return false;
        } else if (!dealNo.equals(other.dealNo))
            return false;
        if (repOwner == null) {
            if (other.repOwner != null)
                return false;
        } else if (!repOwner.equals(other.repOwner))
            return false;
        if (territory == null) {
            if (other.territory != null)
                return false;
        } else if (!territory.equals(other.territory))
            return false;
        return true;
    }

}

