Version implements Comparable<Version>, Serializable { @Override @SuppressWarnings("unchecked") public int compareTo(final Version o) { if (components.length == o.components.length) { return Comparables.compareArrays(components, o.components); } else if (components.length < o.components.length) { int res = Comparables.compareArrays(components, o.components, 0, components.length); if (res == 0) { Comparable component = o.components[components.length]; if (component instanceof String && ((String) component).contains("SNAPSHOT")) { return 1; } else { return -1; } } return res; } else { int res = Comparables.compareArrays(components, o.components, 0, o.components.length); if (res == 0) { Comparable component = components[o.components.length]; if (component instanceof String && ((String) component).contains("SNAPSHOT")) { return -1; } else { return 1; } } return res; } } Version(final String version);  Version(final CharSequence version); @Override @SuppressWarnings("unchecked") int compareTo(final Version o); @Override int hashCode(); @Override boolean equals(final Object obj); String getImage(); Comparable[] getComponents(); Comparable getComponent(final int pos); @SuppressFBWarnings("CLI_CONSTANT_LIST_INDEX") int getMajor(); @SuppressFBWarnings("CLI_CONSTANT_LIST_INDEX") int getMinor(); @SuppressFBWarnings("CLI_CONSTANT_LIST_INDEX") int getPatch(); int getNrComponents(); @Override String toString();  }
@Test public void testVersion2() { Version version1 = new Version("1.1"); Version version2 = new Version("1.1.2"); Assert.assertTrue(version1.compareTo(version2) < 0); }
@Test public void testVersion3() { Version version1 = new Version("1.8.1"); Version version2 = new Version("1.8.0.25p"); Assert.assertTrue(version1.compareTo(version2) > 0); Assert.assertTrue(version2.compareTo(version1) < 0); }
@Test public void testVersion5() { Version version1 = new Version("1.8.1"); Version version2 = new Version("1.8.2-SNAPSHOT"); Assert.assertTrue(version1.compareTo(version2) < 0); }
@Test public void testVersion6() { Version version1 = new Version("1.8.2"); Version version2 = new Version("1.8.2-SNAPSHOT"); Assert.assertTrue(version1.compareTo(version2) > 0); Assert.assertTrue(version2.compareTo(version1) < 0); }
@Test public void testVersion7() { Version version1 = new Version("1.8.3-SNAPSHOT"); Version version2 = new Version("1.8.2-SNAPSHOT"); Assert.assertTrue(version1.compareTo(version2) > 0); Assert.assertTrue(version2.compareTo(version1) < 0); }