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.util.Objects;

@Getter
@Setter
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Embeddable
public class ManualId implements java.io.Serializable {
    private static final long serialVersionUID = -8746197877419636430L;
    @Size(max = 20)
    @NotNull
    @Column(name = "work_id", nullable = false, length = 20)
    private String workId;

    @NotNull
    @Column(name = "vnm", nullable = false)
    private String vnm;

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

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

}