package com.kospo.talk.model;

import jakarta.persistence.Column;
import jakarta.persistence.Embeddable;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.Hibernate;

import java.util.Objects;

@Getter
@Setter
@Embeddable
public class RoleId implements java.io.Serializable {
    private static final long serialVersionUID = -8824456448256682460L;
    @Size(max = 4)
    @NotNull
    @Column(name = "role_id", nullable = false, length = 4)
    private String roleId;

    @Size(max = 10)
    @NotNull
    @Column(name = "sabun", nullable = false, length = 10)
    private String sabun;

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) return false;
        RoleId entity = (RoleId) o;
        return Objects.equals(this.roleId, entity.roleId) &&
                Objects.equals(this.sabun, entity.sabun);
    }

    @Override
    public int hashCode() {
        return Objects.hash(roleId, sabun);
    }

}