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

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

    @NotNull
    @Column(name = "sort", nullable = false)
    private Integer sort;

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof QuestionId that)) return false;
        return Objects.equals(workId, that.workId) && Objects.equals(sort, that.sort);
    }

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