package uk.ac.ebi.quickgo.annotation.model;

import com.google.common.base.Preconditions;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * Represents a set of statistics values for a given type.
 *
 * @author Ricardo Antunes
 */
public class StatisticsByType {
    private final String type;
    private final List<StatisticsValue> values;

    public StatisticsByType(String type) {
        Preconditions.checkArgument(type != null && !type.isEmpty(), "Statistics type cannot be null or empty");
        this.type = type;
        this.values = new ArrayList<>();
    }

    public String getType() {
        return type;
    }

    public void addValue(StatisticsValue value) {
        Preconditions.checkArgument(value != null, "Stats value cannot be null");
        values.add(value);
    }

    public List<StatisticsValue> getValues() {
        return Collections.unmodifiableList(values);
    }

    @Override public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }

        StatisticsByType that = (StatisticsByType) o;

        if (!type.equals(that.type)) {
            return false;
        }
        return values.equals(that.values);

    }

    @Override public int hashCode() {
        int result = type.hashCode();
        result = 31 * result + values.hashCode();
        return result;
    }

    @Override public String toString() {
        return "StatisticsByType{" +
                "type='" + type + '\'' +
                ", values=" + values +
                '}';
    }
}
@@ -321,24 +321,66 @@
 tring type;%0A
+    private final int distinctValueCount;%0A
     private 
@@ -455,16 +455,40 @@
 ing type
+, int distinctValueCount
 ) %7B%0A    
@@ -618,24 +618,78 @@
 ype = type;%0A
+        this.distinctValueCount = distinctValueCount;%0A
         this
@@ -774,32 +774,114 @@
 rn type;%0A    %7D%0A%0A
+    public int getDistinctValueCount()%7B%0A        return distinctValueCount;%0A    %7D%0A%0A
     public void 
@@ -1129,32 +1129,188 @@
 values);%0A    %7D%0A%0A
+    @Override public int hashCode() %7B%0A        int result = type.hashCode();%0A        result = 31 * result + values.hashCode();%0A        return result;%0A    %7D%0A%0A
     @Override pu
@@ -1564,31 +1564,53 @@
 if (
-!type.equals(that.type)
+distinctValueCount != that.distinctValueCount
 ) %7B%0A
@@ -1657,85 +1657,70 @@
     
-return values.equals(that.values);%0A%0A    %7D%0A%0A    @Override public int hashCode(
+if (type != null ? !type.equals(that.type) : that.type != null
 ) %7B%0A
@@ -1731,109 +1731,116 @@
     
-int result = type.hashCode();%0A        result = 31 * result + values.hashCode();%0A        return result
+    return false;%0A        %7D%0A        return values != null ? values.equals(that.values) : that.values == null
 ;%0A  
@@ -1963,16 +1963,79 @@
  '%5C'' +%0A
+                %22, distinctValueCount=%22 + distinctValueCount +%0A
         
@@ -2093,8 +2093,9 @@
 %0A    %7D%0A%7D
+%0A

Add distinct value count.