@Test public void next() { final int major = 1; final int minor = 2; final int patch = 3; final Version version = new Version(major, minor, patch); Assert.assertEquals(version.next(Version.Element.MAJOR), new Version(major+1, 0, 0)); Assert.assertEquals(version.next(Version.Element.MINOR), new Version(major, minor+1, 0)); Assert.assertEquals(version.next(Version.Element.PATCH), new Version(major, minor, patch+1)); }
public Version next(@Nonnull final Version.Element element) { if (element == null) { throw new IllegalArgumentException("null element"); } switch (element) { case MAJOR: if (special == null || this.minor != 0 || this.patch != 0) { return new Version(this.major + 1, 0, 0); } else { return new Version(this.major, 0, 0); } case MINOR: if (special == null || this.patch != 0) { return new Version(this.major, this.minor + 1, 0); } else { return new Version(this.major, this.minor, 0); } case PATCH: if (special == null) { return new Version(this.major, this.minor, this.patch + 1); } else { return new Version(this.major, this.minor, this.patch); } default: throw new IllegalArgumentException("Unknown element <"+element+">"); } }
Version implements Comparable<Version> { public Version next(@Nonnull final Version.Element element) { if (element == null) { throw new IllegalArgumentException("null element"); } switch (element) { case MAJOR: if (special == null || this.minor != 0 || this.patch != 0) { return new Version(this.major + 1, 0, 0); } else { return new Version(this.major, 0, 0); } case MINOR: if (special == null || this.patch != 0) { return new Version(this.major, this.minor + 1, 0); } else { return new Version(this.major, this.minor, 0); } case PATCH: if (special == null) { return new Version(this.major, this.minor, this.patch + 1); } else { return new Version(this.major, this.minor, this.patch); } default: throw new IllegalArgumentException("Unknown element <"+element+">"); } } }
Version implements Comparable<Version> { public Version next(@Nonnull final Version.Element element) { if (element == null) { throw new IllegalArgumentException("null element"); } switch (element) { case MAJOR: if (special == null || this.minor != 0 || this.patch != 0) { return new Version(this.major + 1, 0, 0); } else { return new Version(this.major, 0, 0); } case MINOR: if (special == null || this.patch != 0) { return new Version(this.major, this.minor + 1, 0); } else { return new Version(this.major, this.minor, 0); } case PATCH: if (special == null) { return new Version(this.major, this.minor, this.patch + 1); } else { return new Version(this.major, this.minor, this.patch); } default: throw new IllegalArgumentException("Unknown element <"+element+">"); } } 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 Version next(@Nonnull final Version.Element element) { if (element == null) { throw new IllegalArgumentException("null element"); } switch (element) { case MAJOR: if (special == null || this.minor != 0 || this.patch != 0) { return new Version(this.major + 1, 0, 0); } else { return new Version(this.major, 0, 0); } case MINOR: if (special == null || this.patch != 0) { return new Version(this.major, this.minor + 1, 0); } else { return new Version(this.major, this.minor, 0); } case PATCH: if (special == null) { return new Version(this.major, this.minor, this.patch + 1); } else { return new Version(this.major, this.minor, this.patch); } default: throw new IllegalArgumentException("Unknown element <"+element+">"); } } 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 Version next(@Nonnull final Version.Element element) { if (element == null) { throw new IllegalArgumentException("null element"); } switch (element) { case MAJOR: if (special == null || this.minor != 0 || this.patch != 0) { return new Version(this.major + 1, 0, 0); } else { return new Version(this.major, 0, 0); } case MINOR: if (special == null || this.patch != 0) { return new Version(this.major, this.minor + 1, 0); } else { return new Version(this.major, this.minor, 0); } case PATCH: if (special == null) { return new Version(this.major, this.minor, this.patch + 1); } else { return new Version(this.major, this.minor, this.patch); } default: throw new IllegalArgumentException("Unknown element <"+element+">"); } } 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();  }