package com.jasamedika.medifirst2000.entities;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import javax.persistence.Column;
import javax.persistence.Embeddable;
import javax.validation.constraints.NotNull;
import java.util.Objects;

@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Embeddable
public class AgamaMId implements java.io.Serializable {

	@NotNull(message = "Kd Profile tidak boleh kosong")
	@Column(name = "KdProfile", nullable = false)
	private Short kdProfile;

	@NotNull(message = "Kd Agama tidak boleh kosong")
	@Column(name = "KdAgama", nullable = false)
	private Byte kdAgama;

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		AgamaMId other = (AgamaMId) obj;
		if (!Objects.equals(kdAgama, other.kdAgama))
			return false;
		return Objects.equals(kdProfile, other.kdProfile);
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + kdAgama;
		result = prime * result + kdProfile;
		return result;
	}

}
