package com.kamco.cd.kamcoback.postgres.entity;

import jakarta.persistence.Column;
import jakarta.persistence.Embeddable;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import java.io.Serializable;
import java.util.Objects;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.Hibernate;
import org.hibernate.annotations.ColumnDefault;

@Getter
@Setter
@Embeddable
public class MapSheetAnalSttcEntityId implements Serializable {

  private static final long serialVersionUID = 3649782418773406961L;

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

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

  @NotNull
  @Column(name = "map_sheet_num", nullable = false)
  private Long mapSheetNum;

  @NotNull
  @Column(name = "data_uid", nullable = false)
  private Long dataUid;

  @Size(max = 30)
  @NotNull
  @ColumnDefault("NULL")
  @Column(name = "class_before_cd", nullable = false, length = 30)
  private String classBeforeCd;

  @Size(max = 30)
  @NotNull
  @ColumnDefault("NULL")
  @Column(name = "class_after_cd", nullable = false, length = 30)
  private String classAfterCd;

  @Column(name = "anal_uid")
  private Long analUid;

  @Override
  public boolean equals(Object o) {
    if (this == o) {
      return true;
    }
    if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) {
      return false;
    }
    MapSheetAnalSttcEntityId entity = (MapSheetAnalSttcEntityId) o;
    return Objects.equals(this.targetYyyy, entity.targetYyyy)
        && Objects.equals(this.analUid, entity.analUid)
        && Objects.equals(this.dataUid, entity.dataUid)
        && Objects.equals(this.classAfterCd, entity.classAfterCd)
        && Objects.equals(this.compareYyyy, entity.compareYyyy)
        && Objects.equals(this.classBeforeCd, entity.classBeforeCd)
        && Objects.equals(this.mapSheetNum, entity.mapSheetNum);
  }

  @Override
  public int hashCode() {
    return Objects.hash(
        targetYyyy, analUid, dataUid, classAfterCd, compareYyyy, classBeforeCd, mapSheetNum);
  }
}
