package com.sonymusic.dx.persistence.gras;

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

import java.io.Serializable;

@Embeddable
public class LocalProductVersionPk implements Serializable {

    private static final long serialVersionUID = 1L;

    @Column(name = "prod_vers_no", nullable = false)
    private Long productVersionNo;

    @Column(name = "country_key", nullable = false, length = 3)
    private String countryKey;

    public Long getProductVersionNo() {
        return productVersionNo;
    }

    public void setProductVersionNo(Long productVersionNo) {
        this.productVersionNo = productVersionNo;
    }

    public String getCountryKey() {
        return countryKey;
    }

    public void setCountryKey(String countryKey) {
        this.countryKey = countryKey;
    }

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

    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (!(obj instanceof LocalProductVersionPk))
            return false;
        LocalProductVersionPk other = (LocalProductVersionPk) obj;
        if (getCountryKey() == null) {
            if (other.getCountryKey() != null)
                return false;
        } else if (!getCountryKey().equals(other.getCountryKey()))
            return false;
        if (getProductVersionNo() == null) {
            if (other.getProductVersionNo() != null)
                return false;
        } else if (!getProductVersionNo().equals(other.getProductVersionNo()))
            return false;
        return true;
    }

}
