Version implements Comparable<Version> { @Override public int compareTo(Version other) { if (majorVersion != other.majorVersion) { return majorVersion - other.majorVersion; } if (minorVersion != other.minorVersion) { return minorVersion - other.minorVersion; } return normalizePatchVersion(patchVersion).compareTo(normalizePatchVersion(other.patchVersion)); } Version(int majorVersion, int minorVersion, String patchVersion); static Version fromString(String versionString); int getMajorVersion(); int getMinorVersion(); String getPatchVersion(); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode(); @Override int compareTo(Version other);  }
@Test public void compareTo() throws Exception { assertThat(Version.fromString("1.1"), is(greaterThan(Version.fromString("1.0")))); assertThat(Version.fromString("1.1.1"), is(greaterThan(Version.fromString("1.1.0")))); assertThat(Version.fromString("1.1.1"), is(greaterThan(Version.fromString("1.1")))); }