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
@NoArgsConstructor
@AllArgsConstructor
@Builder
@Embeddable
public class AutoReplyId implements Serializable {
    private static final long serialVersionUID = 8574100646242609185L;
    @Size(max = 4)
    @NotNull
    @Column(name = "work_id", nullable = false, length = 4)
    private String workId;

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

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

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

}