@Test public void testCompareTo() { ComparableObjectItem item1 = new ComparableObjectItem(1, "XYZ"); ComparableObjectItem item2 = new ComparableObjectItem(2, "XYZ"); ComparableObjectItem item3 = new ComparableObjectItem(3, "XYZ"); ComparableObjectItem item4 = new ComparableObjectItem(1, "XYZ"); assertTrue(item2.compareTo(item1) > 0); assertTrue(item3.compareTo(item1) > 0); assertSame(item4.compareTo(item1), 0); assertTrue(item1.compareTo(item2) < 0); }
@Override public int compareTo(ComparableObjectItem that) { return this.x.compareTo(that.x); }
ComparableObjectItem implements Cloneable, Comparable<ComparableObjectItem>,
        Serializable { @Override public int compareTo(ComparableObjectItem that) { return this.x.compareTo(that.x); } }
ComparableObjectItem implements Cloneable, Comparable<ComparableObjectItem>,
        Serializable { @Override public int compareTo(ComparableObjectItem that) { return this.x.compareTo(that.x); } ComparableObjectItem(Comparable x, Object y); }
ComparableObjectItem implements Cloneable, Comparable<ComparableObjectItem>,
        Serializable { @Override public int compareTo(ComparableObjectItem that) { return this.x.compareTo(that.x); } ComparableObjectItem(Comparable x, Object y); @Override int compareTo(ComparableObjectItem that); @Override Object clone(); @Override boolean equals(Object obj); @Override int hashCode(); }
ComparableObjectItem implements Cloneable, Comparable<ComparableObjectItem>,
        Serializable { @Override public int compareTo(ComparableObjectItem that) { return this.x.compareTo(that.x); } ComparableObjectItem(Comparable x, Object y); @Override int compareTo(ComparableObjectItem that); @Override Object clone(); @Override boolean equals(Object obj); @Override int hashCode();  }