content: package org.pmiops.workbench.cdr.model;
  
  import jakarta.persistence.Column;
  import jakarta.persistence.Entity;
  import jakarta.persistence.GeneratedValue;
  import jakarta.persistence.GenerationType;
  import jakarta.persistence.Id;
  import jakarta.persistence.Table;
  import java.sql.Date;
  import java.util.Objects;
  import java.util.StringJoiner;
  
  @Entity
  @Table(name = "cb_person")
  public class DbPerson {
  
    private long personId;
    private Date dob;
    private int ageAtConsent;
    private int ageAtCdr;
    private Boolean isDeceased;
  
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "person_id")
    public long getPersonId() {
      return personId;
    }
  
    public void setPersonId(long personId) {
      this.personId = personId;
    }
  
    @Column(name = "dob")
    public Date getDob() {
      return dob;
    }
  
    public void setDob(Date dob) {
      this.dob = dob;
    }
  
    @Column(name = "age_at_consent")
    public int getAgeAtConsent() {
      return ageAtConsent;
    }
  
    public void setAgeAtConsent(int ageAtConsent) {
      this.ageAtConsent = ageAtConsent;
    }
  
    @Column(name = "age_at_cdr")
    public int getAgeAtCdr() {
      return ageAtCdr;
    }
  
    public void setAgeAtCdr(int ageAtCdr) {
      this.ageAtCdr = ageAtCdr;
    }
  
    @Column(name = "is_deceased")
    public Boolean getIsDeceased() {
      return isDeceased;
    }
  
    public void setIsDeceased(Boolean isDeceased) {
      this.isDeceased = isDeceased;
    }
  
    @Override
    public boolean equals(Object o) {
      if (this == o) {
        return true;
      }
      if (o == null || getClass() != o.getClass()) {
        return false;
      }
      DbPerson dbPerson = (DbPerson) o;
      return ageAtConsent == dbPerson.ageAtConsent
          && ageAtCdr == dbPerson.ageAtCdr
          && isDeceased == dbPerson.isDeceased
          && Objects.equals(dob, dbPerson.dob);
    }
  
    @Override
    public int hashCode() {
      return Objects.hash(dob, ageAtConsent, ageAtCdr, isDeceased);
    }
  
    @Override
    public String toString() {
      return new StringJoiner(", ", DbPerson.class.getSimpleName() + "[", "]")
          .add("personId=" + personId)
          .add("dob=" + dob)
          .add("ageAtConsent=" + ageAtConsent)
          .add("ageAtCdr=" + ageAtCdr)
          .add("isDeceased=" + isDeceased)
          .toString();
    }
  
    public static Builder builder() {
      return new Builder();
    }
  
    public static class Builder {
      private long personId;
      private Date dob;
      private int ageAtConsent;
      private int ageAtCdr;
      private Boolean isDeceased;
  
      private Builder() {}
  
      public Builder addPersonId(long personId) {
        this.personId = personId;
        return this;
      }
  
      public Builder addDob(Date dob) {
        this.dob = dob;
        return this;
      }
  
      public Builder addAgeAtConsent(int ageAtConsent) {
        this.ageAtConsent = ageAtConsent;
        return this;
      }
  
      public Builder addAgeAtCdr(int ageAtCdr) {
        this.ageAtCdr = ageAtCdr;
        return this;
      }
  
      public Builder addIsDeceased(Boolean isDeceased) {
        this.isDeceased = isDeceased;
        return this;
      }
  
      public DbPerson build() {
        DbPerson dbPerson = new DbPerson();
        dbPerson.setPersonId(this.personId);
        dbPerson.setDob(this.dob);
        dbPerson.setAgeAtConsent(this.ageAtConsent);
        dbPerson.setAgeAtCdr(this.ageAtCdr);
        dbPerson.setIsDeceased(this.isDeceased);
        return dbPerson;
      }
    }
  }
  