public final class Version extends Object implements Comparable<Version>
| Modifier and Type | Field and Description |
|---|---|
static Pattern |
SEMVER_DETECT |
static Pattern |
SEMVER_FORMAT |
static String |
SNAPSHOT |
| Constructor and Description |
|---|
Version(int major)
Creates a new version.
|
Version(int major,
int minor)
Creates a new version.
|
Version(int major,
int minor,
int patch)
Creates a new version.
|
Version(int major,
int minor,
int patch,
boolean snapshot)
Creates a new version.
|
Version(int major,
int minor,
int patch,
String preRelease,
String build)
Creates a new version.
|
Version(String text)
Creates a new version from the given text.
|
| Modifier and Type | Method and Description |
|---|---|
int |
compareTo(Version other) |
boolean |
equals(Object o) |
String |
getBuild()
Gets the build label extension.
|
int |
getMajor()
Gets the major version label representing incompatible API changes.
|
int |
getMinor()
Gets the minor version label for functionality in a backwards-compatible manner.
|
int |
getPatch()
Gets the patch label representing backwards-compatible bug fixes.
|
String |
getPreRelease()
Gets the pre-release label extension.
|
int |
hashCode() |
boolean |
isSnapshot()
Indicates whether or not the version represents a snapshot version
(indicated by the "SNAPSHOT" suffix in the pre-release label).
|
static Version |
parse(String version)
Parses the given string and tries to return only one version instance.
|
static Version[] |
parseMulti(String... versions)
Tries to find as many version tags within the given text and returns the result as an array.
|
String |
toString()
Converts this version to a usable version tag.
|
public static final Pattern SEMVER_DETECT
public static final Pattern SEMVER_FORMAT
public static final String SNAPSHOT
public Version(int major)
major - The major version (for incompatible API changes)public Version(int major,
int minor)
major - The major version (for incompatible API changes)minor - The minor version (functionality in a backwards-compatible manner)public Version(int major,
int minor,
int patch)
major - The major version (for incompatible API changes)minor - The minor version (functionality in a backwards-compatible manner)patch - The patch version (backwards-compatible bug fixes)public Version(int major,
int minor,
int patch,
boolean snapshot)
major - The major version (for incompatible API changes)minor - The minor version (functionality in a backwards-compatible manner)patch - The patch version (backwards-compatible bug fixes)snapshot - True if the version represents a snapshot, false if notpublic Version(int major,
int minor,
int patch,
String preRelease,
String build)
major - The major version (for incompatible API changes)minor - The minor version (functionality in a backwards-compatible manner)patch - The patch version (backwards-compatible bug fixes)preRelease - The pre-release tagbuild - The build identifierpublic Version(String text) throws IllegalArgumentException
text - The version textIllegalArgumentException - When the given text does not contain a valid version tagpublic int getMajor()
public int getMinor()
public int getPatch()
public String getPreRelease()
public String getBuild()
public boolean isSnapshot()
public String toString()
public int compareTo(Version other)
compareTo in interface Comparable<Version>public static Version[] parseMulti(String... versions)
versions - The text to look throughpublic static Version parse(String version) throws IllegalArgumentException
version - The version text to parseIllegalArgumentException - when the given string contains no, or more than one versionCopyright © 2014–2015 MountainBlade. All rights reserved.