@Test public void testParseInvalidVersion2() { try { Version.parse("1.5"); } catch (NumberFormatException e) { return; } Assert.assertTrue(false); }
public static Version parse(String version) { int indexFirstDot = version.indexOf('.'); int indexSecondDot = version.indexOf('.', indexFirstDot + 1); if (indexFirstDot == -1 || indexSecondDot == -1) { throw new NumberFormatException("Invalid version format '" + version + "', expected two dots!"); } int indexFirstDash = version.indexOf('-'); int versionEnd; if (indexFirstDash == -1) { versionEnd = version.length(); } else { versionEnd = indexFirstDash; } boolean snapshot = version.endsWith(SNAPSHOT_MARKER); return new Version(Integer.parseInt(version.substring(0, indexFirstDot)), Integer.parseInt(version.substring(indexFirstDot + 1, indexSecondDot)), Integer.parseInt(version.substring(indexSecondDot + 1, versionEnd)), snapshot); }
Version { public static Version parse(String version) { int indexFirstDot = version.indexOf('.'); int indexSecondDot = version.indexOf('.', indexFirstDot + 1); if (indexFirstDot == -1 || indexSecondDot == -1) { throw new NumberFormatException("Invalid version format '" + version + "', expected two dots!"); } int indexFirstDash = version.indexOf('-'); int versionEnd; if (indexFirstDash == -1) { versionEnd = version.length(); } else { versionEnd = indexFirstDash; } boolean snapshot = version.endsWith(SNAPSHOT_MARKER); return new Version(Integer.parseInt(version.substring(0, indexFirstDot)), Integer.parseInt(version.substring(indexFirstDot + 1, indexSecondDot)), Integer.parseInt(version.substring(indexSecondDot + 1, versionEnd)), snapshot); } }
Version { public static Version parse(String version) { int indexFirstDot = version.indexOf('.'); int indexSecondDot = version.indexOf('.', indexFirstDot + 1); if (indexFirstDot == -1 || indexSecondDot == -1) { throw new NumberFormatException("Invalid version format '" + version + "', expected two dots!"); } int indexFirstDash = version.indexOf('-'); int versionEnd; if (indexFirstDash == -1) { versionEnd = version.length(); } else { versionEnd = indexFirstDash; } boolean snapshot = version.endsWith(SNAPSHOT_MARKER); return new Version(Integer.parseInt(version.substring(0, indexFirstDot)), Integer.parseInt(version.substring(indexFirstDot + 1, indexSecondDot)), Integer.parseInt(version.substring(indexSecondDot + 1, versionEnd)), snapshot); } Version(int major, int minor, int revision, boolean snapshot);  Version(int major, int minor, int revision); }
Version { public static Version parse(String version) { int indexFirstDot = version.indexOf('.'); int indexSecondDot = version.indexOf('.', indexFirstDot + 1); if (indexFirstDot == -1 || indexSecondDot == -1) { throw new NumberFormatException("Invalid version format '" + version + "', expected two dots!"); } int indexFirstDash = version.indexOf('-'); int versionEnd; if (indexFirstDash == -1) { versionEnd = version.length(); } else { versionEnd = indexFirstDash; } boolean snapshot = version.endsWith(SNAPSHOT_MARKER); return new Version(Integer.parseInt(version.substring(0, indexFirstDot)), Integer.parseInt(version.substring(indexFirstDot + 1, indexSecondDot)), Integer.parseInt(version.substring(indexSecondDot + 1, versionEnd)), snapshot); } Version(int major, int minor, int revision, boolean snapshot);  Version(int major, int minor, int revision); int getMajor(); int getMinor(); int getRevision(); boolean isSnapshot(); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); static Version parse(String version); static Version currentVersion(); }
Version { public static Version parse(String version) { int indexFirstDot = version.indexOf('.'); int indexSecondDot = version.indexOf('.', indexFirstDot + 1); if (indexFirstDot == -1 || indexSecondDot == -1) { throw new NumberFormatException("Invalid version format '" + version + "', expected two dots!"); } int indexFirstDash = version.indexOf('-'); int versionEnd; if (indexFirstDash == -1) { versionEnd = version.length(); } else { versionEnd = indexFirstDash; } boolean snapshot = version.endsWith(SNAPSHOT_MARKER); return new Version(Integer.parseInt(version.substring(0, indexFirstDot)), Integer.parseInt(version.substring(indexFirstDot + 1, indexSecondDot)), Integer.parseInt(version.substring(indexSecondDot + 1, versionEnd)), snapshot); } Version(int major, int minor, int revision, boolean snapshot);  Version(int major, int minor, int revision); int getMajor(); int getMinor(); int getRevision(); boolean isSnapshot(); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); static Version parse(String version); static Version currentVersion(); static final Version DEV_VERSION; }