package com.infoclinika.pdx.projection;

import java.util.List;
import java.util.Objects;

/**
 * DTO to hold statistics by primary site and molecular subtypes.
 */
public class PrimarySiteStatisticsDto extends AnnotationStatistics {
    private List<BaseStatistics> children;

    /**
     * Default constructor.
     */
    public PrimarySiteStatisticsDto() {
    }

    /**
     * Initializes all fields using {@link AnnotationStatistics} entity.
     */
    public PrimarySiteStatisticsDto(AnnotationStatistics statistics, List<BaseStatistics> children) {
        super(statistics.getId(), statistics.getName(), statistics.getCount());
        this.children = children;
    }

    public List<BaseStatistics> getChildren() {
        return children;
    }

    public void setChildren(List<BaseStatistics> children) {
        this.children = children;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        final PrimarySiteStatisticsDto that = (PrimarySiteStatisticsDto) o;
        return getCount() == that.getCount()
               && Objects.equals(getId(), that.getId())
               && Objects.equals(getName(), that.getName())
               && Objects.equals(getChildren(), that.getChildren());
    }

    @Override
    public int hashCode() {
        return Objects.hash(super.hashCode(), getChildren());
    }

    @Override
    public String toString() {
        return "PrimarySiteStatisticsDto{"
               + "id=" + getId()
               + ", name='" + getName() + '\''
               + ", count=" + getCount()
               + ", children=" + getChildren()
               + '}';
    }
}
