@Test public void compare() { final Version v0_95 = new Version("0.95"); final Version v1 = new Version("1.0"); final Version v1_2 = new Version("1.2"); final Version v1_10 = new Version("1.10"); final Version v1_10_17_1043 = new Version("1.10.17.1043"); final Version v1_10_17_1043b = new Version("1.10.17.1043"); final Version v1_10_17_1044 = new Version("1.10.17.1044"); final Version v1_10_17_1045 = new Version("1.10.17.1045"); final Version v600SNAPSHOT = new Version("6.0.0-SNAPSHOT"); final Version v600 = new Version("6.0.0"); final Version v601SNAPSHOT = new Version("6.0.1-SNAPSHOT"); final Version v601 = new Version("6.0.1"); final Version v610SNAPSHOT = new Version("6.1.0-SNAPSHOT"); final Version v610 = new Version("6.1.0"); compare(v0_95, v1); equal(v1_10_17_1043, v1_10_17_1043b); compare(v1_2, v1_10); compare(v1_10_17_1043, v1_10_17_1044); compare(v1_10_17_1043, v1_10_17_1045); compare(v1_10_17_1044, v1_10_17_1045); final Version v1_2b = new Version("1.2b"); final Version v1_2b2 = new Version("1.2b2"); compare(v1_2b, v1_2); compare(v1_2b, v1_2b2); final Version v1_2rc = new Version("1.2rc"); final Version v1_2rc2 = new Version("1.2rc2"); compare(v1_2rc, v1_2); compare(v1_2rc, v1_2rc2); compare("1.2rc1", "1.2"); compare("1.2b1", "1.2"); compare("1.2b1", "1.2rc1"); compare("1.2rc1", "1.2rc2"); compare("1.2b1", "1.2b2"); assertEquals("6.0-SNAPSHOT", v600SNAPSHOT.toString()); assertEquals("6.0", v600.toString()); assertEquals("6.0.1-SNAPSHOT", v601SNAPSHOT.toString()); assertEquals("6.0.1", v601.toString()); assertEquals("6.1-SNAPSHOT", v610SNAPSHOT.toString()); assertEquals("6.1", v610.toString()); }
private int compare(final int i1, final int i2) { if (i1 < i2) { return -1; } else if (i1 > i2) { return 1; } else { return 0; } }
Version implements Comparable<Version>, Serializable { private int compare(final int i1, final int i2) { if (i1 < i2) { return -1; } else if (i1 > i2) { return 1; } else { return 0; } } }
Version implements Comparable<Version>, Serializable { private int compare(final int i1, final int i2) { if (i1 < i2) { return -1; } else if (i1 > i2) { return 1; } else { return 0; } } Version(final String version);  Version(final int majorRelease, final int minorRelease);  Version(final int majorRelease, final int minorRelease, final int patchLevel);  Version(final int majorRelease, final int minorRelease, final int patchLevel, final int buildNumber); }
Version implements Comparable<Version>, Serializable { private int compare(final int i1, final int i2) { if (i1 < i2) { return -1; } else if (i1 > i2) { return 1; } else { return 0; } } Version(final String version);  Version(final int majorRelease, final int minorRelease);  Version(final int majorRelease, final int minorRelease, final int patchLevel);  Version(final int majorRelease, final int minorRelease, final int patchLevel, final int buildNumber); int getMajorRelease(); int getMinorRelease(); int getPatchLevel(); int getBuildNumber(); Version setBetaVersion(final int betaVersion); int getBetaVersion(); boolean isBeta(); int getReleaseCandidateVersion(); Version setReleaseCandidateVersion(final int releaseCandidateVersion); boolean isReleaseCandidate(); boolean isSnapshot(); @Override int compareTo(final Version o); @Override String toString(); }
Version implements Comparable<Version>, Serializable { private int compare(final int i1, final int i2) { if (i1 < i2) { return -1; } else if (i1 > i2) { return 1; } else { return 0; } } Version(final String version);  Version(final int majorRelease, final int minorRelease);  Version(final int majorRelease, final int minorRelease, final int patchLevel);  Version(final int majorRelease, final int minorRelease, final int patchLevel, final int buildNumber); int getMajorRelease(); int getMinorRelease(); int getPatchLevel(); int getBuildNumber(); Version setBetaVersion(final int betaVersion); int getBetaVersion(); boolean isBeta(); int getReleaseCandidateVersion(); Version setReleaseCandidateVersion(final int releaseCandidateVersion); boolean isReleaseCandidate(); boolean isSnapshot(); @Override int compareTo(final Version o); @Override String toString();  }