Version implements Comparable<Version> { @Override public int compareTo(Version other) { return this.semver.compareTo(other.semver); } Version(int major, int minor, int patch);  Version(int major, int minor, int patch, boolean snapshot);  Version(String version); private  Version(com.github.zafarkhaja.semver.Version semver); int getMajor(); int getMinor(); int getPatch(); boolean isSnapshot(); Version getSnapshot(); Version getNextMajorVersion(); Version getNextMinorVersion(); Version getNextPatchVersion(); @Override boolean equals(Object obj); @Override int hashCode(); @Override String toString(); @Override int compareTo(Version other); static final Version DEFAULT; }
@Test public void snapshotVersionLessThanRealVersion() { Version snapshot = new Version("1.2.3-SNAPSHOT"); Version real = new Version("1.2.3"); assertNotEquals(snapshot, real); assertTrue(snapshot.compareTo(real) < 0); }
@Test public void compareVersions() { assertEquals(0, new Version(1, 0, 0).compareTo(new Version(1, 0, 0))); assertEquals(-1, new Version(1, 0, 0).compareTo(new Version(2, 0, 0))); assertEquals(1, new Version(2, 0, 0).compareTo(new Version(1, 0, 0))); assertEquals(1, new Version(1, 1, 0).compareTo(new Version(1, 0, 0))); assertEquals(-1, new Version(1, 0, 0).compareTo(new Version(1, 1, 0))); assertEquals(1, new Version(1, 0, 1).compareTo(new Version(1, 0, 0))); assertEquals(-1, new Version(1, 0, 0).compareTo(new Version(1, 0, 1))); }