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.*;
import org.hibernate.Hibernate;

import java.io.Serializable;
import java.util.Objects;

@Getter
@Setter
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Embeddable
public class PiUserId implements Serializable {
    private static final long serialVersionUID = -8603174846425880017L;
    @Size(max = 10)
    @NotNull
    @Column(name = "sabun", nullable = false, length = 10)
    private String sabun;

    @Size(max = 4)
    @NotNull
    @Column(name = "work_id", nullable = false, length = 4)
    private String workId;

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

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

}