AnnotationTriplet implements Comparable<AnnotationTriplet> { @Override public int compareTo(final AnnotationTriplet o) { if (this.annotation.equals(o.annotation)){ return this.order.compareTo(o.order); } else { return this.annotation.compareTo(o.annotation); } } AnnotationTriplet(final String annotation, final Integer colNumber, final Integer order); @Override int compareTo(final AnnotationTriplet o);  }
@Test public void testCompareTo() throws Exception { AnnotationTriplet t0 = new AnnotationTriplet("column", 0, 0); AnnotationTriplet t1 = new AnnotationTriplet("column", 1, 1); AnnotationTriplet t2 = new AnnotationTriplet("deco", 2, 1); AnnotationTriplet t3 = new AnnotationTriplet("deco", 3, 2); AnnotationTriplet t4 = new AnnotationTriplet("row", 4, 1); AnnotationTriplet t5 = new AnnotationTriplet("row", 5, 2); AnnotationTriplet t6 = new AnnotationTriplet("skip", 6, 1); AnnotationTriplet t7 = new AnnotationTriplet("skip", 7, 2); AnnotationTriplet t8 = new AnnotationTriplet("value", 8, 1); AnnotationTriplet t9 = new AnnotationTriplet("value", 9, 2); List<AnnotationTriplet> l = Arrays.asList(t1, t3, t5, t4, t7, t6, t9, t8, t0, t2); Collections.sort(l); Assertions.assertThat(l.get(0)).isEqualTo(t0); Assertions.assertThat(l.get(1)).isEqualTo(t1); Assertions.assertThat(l.get(2)).isEqualTo(t2); Assertions.assertThat(l.get(3)).isEqualTo(t3); Assertions.assertThat(l.get(4)).isEqualTo(t4); Assertions.assertThat(l.get(5)).isEqualTo(t5); Assertions.assertThat(l.get(6)).isEqualTo(t6); Assertions.assertThat(l.get(7)).isEqualTo(t7); Assertions.assertThat(l.get(8)).isEqualTo(t8); Assertions.assertThat(l.get(9)).isEqualTo(t9); }