package com.sonymusic.dx.persistence.gras;

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

import java.io.Serializable;

@Embeddable
public class LocalProductPk implements Serializable {

    private static final long serialVersionUID = 1L;

    @Column(name = "loc_prod_no", nullable = false, length = 16)
    private String localProductNumber;

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

    protected LocalProductPk() {}

    public LocalProductPk(String localProductNumber, String countryKey) {
        this.localProductNumber = localProductNumber;
        this.countryKey = countryKey;
    }

    public String getLocalProductNumber() {
        return localProductNumber;
    }

    public void setLocalProductNumber(String localProductNumber) {
        this.localProductNumber = localProductNumber;
    }

    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 + ((getLocalProductNumber() == null) ? 0 : getLocalProductNumber().hashCode());
        return result;
    }

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

}
