package com.kamco.cd.kamcoback.postgres.entity;

import jakarta.persistence.Column;
import jakarta.persistence.Embeddable;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import java.io.Serializable;
import java.util.Objects;
import java.util.UUID;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.Hibernate;

@Getter
@Setter
@Embeddable
public class MemberRoleEntityId implements Serializable {

  private static final long serialVersionUID = 9130416001060414347L;

  @NotNull
  @Column(name = "member_uuid", nullable = false)
  private UUID memberUuid;

  @Size(max = 50)
  @NotNull
  @Column(name = "role_name", nullable = false, length = 50)
  private String roleName;

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

  @Override
  public int hashCode() {
    return Objects.hash(memberUuid, roleName);
  }
}
