1 package com.stateofflow.eclipse.metrics.export.html.histogram;
2
3 import com.stateofflow.eclipse.metrics.util.CounterMap;
4
5 abstract class Range implements Comparable<Range> {
6 public static final Range OUT = new Range(0, "Out of Range") {
7 @Override
8 public int getValue(final Category category, final CounterMap<Category> categoryToYValueMap) {
9 return category.getOutOfRangeValue(categoryToYValueMap);
10 }
11 };
12
13 public static final Range IN = new Range(1, "In Range") {
14 @Override
15 public int getValue(final Category category, final CounterMap<Category> categoryToYValueMap) {
16 return category.getInRangeValue(categoryToYValueMap);
17 }
18 };
19
20 private final int index;
21 private final String description;
22
23 public Range(final int index, final String description) {
24 this.index = index;
25 this.description = description;
26 }
27
28 public int compareTo(final Range that) {
29 return index - that.index;
30 }
31
32 public int getIndex() {
33 return index;
34 }
35
36 public abstract int getValue(Category category, CounterMap<Category> categoryToYValueMap);
37
38 @Override
39 public String toString() {
40 return description;
41 }
42 }