package com.infoclinika.pdx.projection;

import java.util.Objects;

/**
 * Projection for Sample entity.
 */
public class SampleDto implements IdAndName {
    private Long id;
    private String name;
    private String primarySite;
    private String subType;

    /**
     * Initializes all fields {@link AggregateSampleDto}.
     */
    public SampleDto(AggregateSampleDto dto) {
        this.id = dto.getId();
        this.name = dto.getName();
        this.primarySite = dto.getPrimarySite().getName();
        this.subType = dto.getSubType();
    }

    /**
     * Initializes all fields using DTOs.
     */
    public SampleDto(IdAndNameDto sample, String primarySite) {
        this.id = sample.getId();
        this.name = sample.getName();
        this.primarySite = primarySite;
    }

    /**
     * Initializes all fields using DTOs and subtype.
     */
    public SampleDto(IdAndNameDto sample, String primarySite, String subType) {
        this.id = sample.getId();
        this.name = sample.getName();
        this.primarySite = primarySite;
        this.subType = subType;
    }

    /**
     * Initializes all fields.
     */
    public SampleDto(long id, String name, String primarySite, String subType) {
        this.id = id;
        this.name = name;
        this.primarySite = primarySite;
        this.subType = subType;
    }

    @Override
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @Override
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPrimarySite() {
        return primarySite;
    }

    public void setPrimarySite(String primarySite) {
        this.primarySite = primarySite;
    }

    public String getSubType() {
        return subType;
    }

    public void setSubType(String subType) {
        this.subType = subType;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        final SampleDto dto = (SampleDto) o;
        return Objects.equals(getId(), dto.getId())
               && Objects.equals(getName(), dto.getName())
               && Objects.equals(getSubType(), dto.getSubType())
               && Objects.equals(getPrimarySite(), dto.getPrimarySite());
    }

    @Override
    public int hashCode() {
        return Objects.hash(getId(), getName(), getPrimarySite());
    }

    @Override
    public String toString() {
        return "SampleDto{"
               + "id=" + id
               + ", name='" + name + '\''
               + ", primarySite='" + primarySite + '\''
               + ", subType='" + subType + '\''
               + '}';
    }
}
