package com.sonymusic.dx.persistence.gras;

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

import java.io.Serializable;

@Embeddable
public class RecordingProjectPublisherPk implements Serializable {

    private static final long serialVersionUID = 1L;

    @Column(name = "rec_project_id", nullable = false)
    private Long recordingProjectId;

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

    @Column(name = "publisher_no", nullable = false)
    private Long publisherNo;

    public RecordingProjectPublisherPk() {}

    public RecordingProjectPublisherPk(Long recordingProjectId, String countryKey, Long publisherNo) {
        this.recordingProjectId = recordingProjectId;
        this.countryKey = countryKey;
        this.publisherNo = publisherNo;
    }

    public Long getRecordingProjectId() {
        return recordingProjectId;
    }

    public void setRecordingProjectId(Long recordingProjectId) {
        this.recordingProjectId = recordingProjectId;
    }

    public String getCountryKey() {
        return countryKey;
    }

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

    public Long getPublisherNo() {
        return publisherNo;
    }

    public void setPublisherNo(Long publisherNo) {
        this.publisherNo = publisherNo;
    }

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

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

}
