@Test(expected=IllegalArgumentException.class) public void shouldInvalidVersion2NotBeParsed() { Version.parse("a.2.3"); }
public static Version parse(@Nonnull final String version) { final Matcher matcher = Version.PATTERN.matcher(version); if (!matcher.matches()) { throw new IllegalArgumentException("<"+version+"> does not match format "+Version.FORMAT); } final int major = Integer.valueOf(matcher.group(1)); final int minor = Integer.valueOf(matcher.group(2)); final int patch; final String patchMatch = matcher.group(3); if (StringUtils.isNotEmpty(patchMatch)) { patch = Integer.valueOf(patchMatch); } else { patch = 0; } final String separator = matcher.group(4); final String special = matcher.group(5); return new Version(major, minor, patch, separator, "".equals(special) ? null : special); }
Version implements Comparable<Version> { public static Version parse(@Nonnull final String version) { final Matcher matcher = Version.PATTERN.matcher(version); if (!matcher.matches()) { throw new IllegalArgumentException("<"+version+"> does not match format "+Version.FORMAT); } final int major = Integer.valueOf(matcher.group(1)); final int minor = Integer.valueOf(matcher.group(2)); final int patch; final String patchMatch = matcher.group(3); if (StringUtils.isNotEmpty(patchMatch)) { patch = Integer.valueOf(patchMatch); } else { patch = 0; } final String separator = matcher.group(4); final String special = matcher.group(5); return new Version(major, minor, patch, separator, "".equals(special) ? null : special); } }
Version implements Comparable<Version> { public static Version parse(@Nonnull final String version) { final Matcher matcher = Version.PATTERN.matcher(version); if (!matcher.matches()) { throw new IllegalArgumentException("<"+version+"> does not match format "+Version.FORMAT); } final int major = Integer.valueOf(matcher.group(1)); final int minor = Integer.valueOf(matcher.group(2)); final int patch; final String patchMatch = matcher.group(3); if (StringUtils.isNotEmpty(patchMatch)) { patch = Integer.valueOf(patchMatch); } else { patch = 0; } final String separator = matcher.group(4); final String special = matcher.group(5); return new Version(major, minor, patch, separator, "".equals(special) ? null : special); } Version(@Nonnegative final int major, @Nonnegative final int minor, @Nonnegative final int patch);  Version(@Nonnegative final int major, @Nonnegative final int minor, @Nonnegative final int patch, @Nullable final String separator, @Nullable final String special); }
Version implements Comparable<Version> { public static Version parse(@Nonnull final String version) { final Matcher matcher = Version.PATTERN.matcher(version); if (!matcher.matches()) { throw new IllegalArgumentException("<"+version+"> does not match format "+Version.FORMAT); } final int major = Integer.valueOf(matcher.group(1)); final int minor = Integer.valueOf(matcher.group(2)); final int patch; final String patchMatch = matcher.group(3); if (StringUtils.isNotEmpty(patchMatch)) { patch = Integer.valueOf(patchMatch); } else { patch = 0; } final String separator = matcher.group(4); final String special = matcher.group(5); return new Version(major, minor, patch, separator, "".equals(special) ? null : special); } Version(@Nonnegative final int major, @Nonnegative final int minor, @Nonnegative final int patch);  Version(@Nonnegative final int major, @Nonnegative final int minor, @Nonnegative final int patch, @Nullable final String separator, @Nullable final String special); static Version parse(@Nonnull final String version); Version next(@Nonnull final Version.Element element); Version toReleaseVersion(); boolean isInDevelopment(); boolean isStable(); boolean isSnapshot(); boolean isCompatible(Version version); @Override int hashCode(); @Override boolean equals(@Nullable final Object object); @Override int compareTo(final Version other); @Override String toString(); }
Version implements Comparable<Version> { public static Version parse(@Nonnull final String version) { final Matcher matcher = Version.PATTERN.matcher(version); if (!matcher.matches()) { throw new IllegalArgumentException("<"+version+"> does not match format "+Version.FORMAT); } final int major = Integer.valueOf(matcher.group(1)); final int minor = Integer.valueOf(matcher.group(2)); final int patch; final String patchMatch = matcher.group(3); if (StringUtils.isNotEmpty(patchMatch)) { patch = Integer.valueOf(patchMatch); } else { patch = 0; } final String separator = matcher.group(4); final String special = matcher.group(5); return new Version(major, minor, patch, separator, "".equals(special) ? null : special); } Version(@Nonnegative final int major, @Nonnegative final int minor, @Nonnegative final int patch);  Version(@Nonnegative final int major, @Nonnegative final int minor, @Nonnegative final int patch, @Nullable final String separator, @Nullable final String special); static Version parse(@Nonnull final String version); Version next(@Nonnull final Version.Element element); Version toReleaseVersion(); boolean isInDevelopment(); boolean isStable(); boolean isSnapshot(); boolean isCompatible(Version version); @Override int hashCode(); @Override boolean equals(@Nullable final Object object); @Override int compareTo(final Version other); @Override String toString();  }