package com.infoclinika.pdx.projection;

import com.infoclinika.pdx.domain.PrimarySite;
import com.infoclinika.pdx.domain.sample.SampleType;

import java.util.Objects;

/**
 * Class to hold statistics by primary site.
 */
public class PrimarySiteStatistics extends BaseStatistics {
    private Long id;
    private SampleType type;

    /**
     * Constructor with all fields.
     */
    public PrimarySiteStatistics(Long id, String name, SampleType type, long count) {
        super(name, count);
        this.id = id;
        this.type = type;
    }

    public PrimarySiteStatistics(PrimarySite primarySite, SampleType type, long count) {
        this(primarySite.getId(), primarySite.getName(), type, count);
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public SampleType getType() {
        return type;
    }

    public void setType(SampleType type) {
        this.type = type;
    }

    @SuppressWarnings("OverlyComplexBooleanExpression")
    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        PrimarySiteStatistics that = (PrimarySiteStatistics) o;
        return getCount() == that.getCount()
                && Objects.equals(getId(), that.getId())
                && Objects.equals(getName(), that.getName())
                && getType() == that.getType();
    }

    @Override
    public int hashCode() {
        return Objects.hash(getId(), getName(), getType(), getCount());
    }

    @Override
    public String toString() {
        return "PrimarySiteStatistics{"
                + "id=" + id
                + ", name='" + getName() + '\''
                + ", type=" + type
                + ", count=" + getCount()
                + '}';
    }
}
