@Test public void testParse() { assertEquals(new Version(1), Version.parse("1")); assertEquals(new Version(1, 2, 3), Version.parse("1.2.3")); assertEquals(new Version(1, "SNAPSHOT"), Version.parse("1-SNAPSHOT")); assertEquals(new Version(1, 2, 3, "SNAPSHOT"), Version.parse("1.2.3-SNAPSHOT")); }
public static Version parse(String str) { String extension; int p = str.indexOf('-'); if (p != -1) { extension = str.substring(p + 1); str = str.substring(0, p); } else { extension = null; } String[] partStrs = str.split("\\."); int[] parts = new int[partStrs.length]; for (int i = 0; i < partStrs.length; i++) { parts[i] = Integer.parseInt(partStrs[i]); } return new Version(parts, extension); }
Version implements Comparable<Version>, Serializable { public static Version parse(String str) { String extension; int p = str.indexOf('-'); if (p != -1) { extension = str.substring(p + 1); str = str.substring(0, p); } else { extension = null; } String[] partStrs = str.split("\\."); int[] parts = new int[partStrs.length]; for (int i = 0; i < partStrs.length; i++) { parts[i] = Integer.parseInt(partStrs[i]); } return new Version(parts, extension); } }
Version implements Comparable<Version>, Serializable { public static Version parse(String str) { String extension; int p = str.indexOf('-'); if (p != -1) { extension = str.substring(p + 1); str = str.substring(0, p); } else { extension = null; } String[] partStrs = str.split("\\."); int[] parts = new int[partStrs.length]; for (int i = 0; i < partStrs.length; i++) { parts[i] = Integer.parseInt(partStrs[i]); } return new Version(parts, extension); } Version(int... parts);  Version(int part0, String extension);  Version(int part0, int part1, String extension);  Version(int part0, int part1, int part2,  String extension);  Version(int[] parts, String extension); }
Version implements Comparable<Version>, Serializable { public static Version parse(String str) { String extension; int p = str.indexOf('-'); if (p != -1) { extension = str.substring(p + 1); str = str.substring(0, p); } else { extension = null; } String[] partStrs = str.split("\\."); int[] parts = new int[partStrs.length]; for (int i = 0; i < partStrs.length; i++) { parts[i] = Integer.parseInt(partStrs[i]); } return new Version(parts, extension); } Version(int... parts);  Version(int part0, String extension);  Version(int part0, int part1, String extension);  Version(int part0, int part1, int part2,  String extension);  Version(int[] parts, String extension); int[] getParts(); String getExtension(); boolean isAtLeast(Version version); @Override int compareTo(Version o); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString(); static Version parse(String str); }
Version implements Comparable<Version>, Serializable { public static Version parse(String str) { String extension; int p = str.indexOf('-'); if (p != -1) { extension = str.substring(p + 1); str = str.substring(0, p); } else { extension = null; } String[] partStrs = str.split("\\."); int[] parts = new int[partStrs.length]; for (int i = 0; i < partStrs.length; i++) { parts[i] = Integer.parseInt(partStrs[i]); } return new Version(parts, extension); } Version(int... parts);  Version(int part0, String extension);  Version(int part0, int part1, String extension);  Version(int part0, int part1, int part2,  String extension);  Version(int[] parts, String extension); int[] getParts(); String getExtension(); boolean isAtLeast(Version version); @Override int compareTo(Version o); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString(); static Version parse(String str);  }