FormatVersion implements Comparable<FormatVersion> { @Override public int compareTo(FormatVersion o) { int length = Math.max(this.versionParts.length, o.versionParts.length); for (int i = 0; i < length; i++) { int version1 = i < this.versionParts.length ? Integer.valueOf(this.versionParts[i]).intValue() : 0; int version2 = i < o.versionParts.length ? Integer.valueOf(o.versionParts[i]).intValue() : 0; if (version1 < version2) { return -1; } if (version1 > version2) { return 1; } } return 0; } FormatVersion(String versionString); @Override int compareTo(FormatVersion o); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode();  }
@Test public void compareToTest() { assertThat(compareFormatVersion("2.10", "1.10")).isGreaterThan(0); assertThat(compareFormatVersion("2.10", "2.1")).isGreaterThan(0); assertThat(compareFormatVersion("2.10", "2")).isGreaterThan(0); assertThat(compareFormatVersion("1.10", "2.10")).isLessThan(0); assertThat(compareFormatVersion("2.1", "2.10")).isLessThan(0); assertThat(compareFormatVersion("2", "2.10")).isLessThan(0); }