package com.infoclinika.pdx.projection;

import com.infoclinika.pdx.domain.sample.SampleType;

import java.util.Objects;

/**
 * Class to hold statistics by string.
 */
public class BaseStatistics {
    private String name;
    private long count;

    public BaseStatistics() {
    }

    public BaseStatistics(String name, Number count) {
        this.name = name;
        this.count = count.longValue();
    }

    public BaseStatistics(SampleType type, Number count) {
        this.name = type.name();
        this.count = count.longValue();
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public long getCount() {
        return count;
    }

    public void setCount(Number count) {
        this.count = count.longValue();
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        final BaseStatistics that = (BaseStatistics) o;
        return Objects.equals(getName(), that.getName())
               && Objects.equals(getCount(), that.getCount());
    }

    @Override
    public int hashCode() {
        return Objects.hash(getName(), getCount());
    }

    @Override
    public String toString() {
        return "BaseStatistics{"
               + "name='" + name + '\''
               + ", count=" + count
               + '}';
    }
}
