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.time.LocalDateTime;
import java.util.Date;
import java.util.Objects;

@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Builder
@Embeddable
public class TalkMessageId implements java.io.Serializable {
    private static final long serialVersionUID = -2383999741202453456L;
    @Size(max = 100)
    @NotNull
    @Column(name = "talk_id", nullable = false, length = 100)
    private String talkId;

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

    @NotNull
    @Column(name = "ins_date", nullable = false)
    private LocalDateTime insDate;

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

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

}