GeneIdentifier implements Comparable<GeneIdentifier> { public int compareTo(GeneIdentifier otherGeneIdentifier) { Objects.requireNonNull(otherGeneIdentifier); return GeneIdentifier.compare(this, otherGeneIdentifier); } private  GeneIdentifier(Builder builder); String getGeneId(); String getGeneSymbol(); String getHgncId(); String getHgncSymbol(); String getEntrezId(); @JsonIgnore Integer getEntrezIdAsInteger(); boolean hasEntrezId(); String getEnsemblId(); String getUcscId(); int compareTo(GeneIdentifier otherGeneIdentifier); static int compare(GeneIdentifier g1, GeneIdentifier g2); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); static Builder builder(); static final String EMPTY_FIELD; }
@Test public void testCompareTo() { GeneIdentifier first = GeneIdentifier.builder().geneSymbol("1ABC").build(); GeneIdentifier second = GeneIdentifier.builder().geneSymbol("1BBC").build(); GeneIdentifier third = GeneIdentifier.builder().geneSymbol("2BCD").build(); List<GeneIdentifier> geneIdentifiers = Arrays.asList(second, first, third); geneIdentifiers.sort(GeneIdentifier::compareTo); assertThat(geneIdentifiers, equalTo(Arrays.asList(first, second, third))); }