CustomTimeBucket implements Serializable, Comparable<CustomTimeBucket> { @Override public int compareTo(CustomTimeBucket other) { if (this.numMillis < other.numMillis) { return -1; } else if (this.numMillis == other.numMillis) { return 0; } return 1; } private  CustomTimeBucket();  CustomTimeBucket(String timeBucketText);  CustomTimeBucket(TimeBucket timeBucket, long count);  CustomTimeBucket(TimeBucket timeBucket); boolean isUnit(); TimeBucket getTimeBucket(); long getCount(); long getNumMillis(); long toMillis(long multCount); long roundDown(long timestamp); String getText(); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); @Override int compareTo(CustomTimeBucket other); static final String TIME_BUCKET_NAME_REGEX; static final Pattern TIME_BUCKET_NAME_PATTERN; }
@Test public void compareTest() { CustomTimeBucket bigger = new CustomTimeBucket("180m"); CustomTimeBucket smaller = new CustomTimeBucket("2h"); Assert.assertTrue(bigger.compareTo(bigger) == 0); Assert.assertTrue(smaller.compareTo(smaller) == 0); Assert.assertTrue(bigger.compareTo(smaller) > 0); Assert.assertTrue(smaller.compareTo(bigger) < 0); smaller = new CustomTimeBucket("91m"); Assert.assertTrue(bigger.compareTo(smaller) > 0); Assert.assertTrue(smaller.compareTo(bigger) < 0); }