@Immutable public final class Version extends Object implements IComparable<Version>
| Modifier and Type | Field and Description |
|---|---|
static boolean |
DEFAULT_PRINT_ZERO_ELEMENTS
Default value for printing zero elements in getAsString
|
static Version |
DEFAULT_VERSION |
static String |
DEFAULT_VERSION_STRING
default version if nothing is specified.
|
| Constructor and Description |
|---|
Version(int nMajor)
Create a new version with major version only.
|
Version(int nMajor,
int nMinor)
Create a new version with major and minor version only.
|
Version(int nMajor,
int nMinor,
int nMicro)
Create a new version with major, minor and micro version number.
|
Version(int nMajor,
int nMinor,
int nMicro,
String sQualifier)
Create a new version with 3 integer values and a qualifier.
|
| Modifier and Type | Method and Description |
|---|---|
int |
compareTo(Version rhs)
Compares two Version objects.
|
boolean |
equals(Object o) |
String |
getAsString() |
String |
getAsString(boolean bPrintZeroElements)
Get the string representation of the version number.
|
String |
getAsString(boolean bPrintZeroElements,
boolean bPrintAtLeastMajorAndMinor)
Get the string representation of the version number.
|
String |
getAsStringMajorMinor()
Get the string representation of the version number but only major and
minor version number.
|
String |
getAsStringMajorMinorMicro()
Get the string representation of the version number but only major and
minor and micro version number.
|
int |
getMajor() |
int |
getMicro() |
int |
getMinor() |
String |
getQualifier() |
int |
hashCode() |
boolean |
hasQualifier() |
static Version |
parse(String sVersionString)
Construct a version object from a string.
|
static Version |
parse(String sVersionString,
boolean bOldVersion)
Deprecated.
Since v10.0.1 in favour of
parse(String) and
parseDotOnly(String) |
static Version |
parseDotOnly(String sVersionString)
Construct a version object from a string.
|
String |
toString() |
public static final String DEFAULT_VERSION_STRING
public static final Version DEFAULT_VERSION
public static final boolean DEFAULT_PRINT_ZERO_ELEMENTS
public Version(@Nonnegative int nMajor)
nMajor - major versionIllegalArgumentException - if the parameter is < 0public Version(@Nonnegative int nMajor, @Nonnegative int nMinor)
nMajor - major versionnMinor - minor versionIllegalArgumentException - if any of the parameters is < 0public Version(@Nonnegative int nMajor, @Nonnegative int nMinor, @Nonnegative int nMicro)
nMajor - major versionnMinor - minor versionnMicro - micro versionIllegalArgumentException - if any of the parameters is < 0public Version(@Nonnegative int nMajor, @Nonnegative int nMinor, @Nonnegative int nMicro, @Nullable String sQualifier)
nMajor - major versionnMinor - minor versionnMicro - micro versionsQualifier - the version qualifier - may be null. If a qualifier is supplied, it
may neither contain the "." or the "," character since they are used
to determine the fields of a version and to separate 2 versions in a
VersionRange.IllegalArgumentException - if any of the numeric parameters is < 0 or if the qualifier
contains a forbidden character@Nonnegative public int getMajor()
@Nonnegative public int getMinor()
@Nonnegative public int getMicro()
public boolean hasQualifier()
public int compareTo(@Nonnull Version rhs)
compareTo in interface Comparable<Version>rhs - the version to compare toIllegalArgumentException - if the parameter is null@Nonnull public String getAsString(boolean bPrintZeroElements)
bPrintZeroElements - If true than trailing zeroes are printed, otherwise
printed zeroes are not printed.null.@Nonnull public String getAsString(boolean bPrintZeroElements, boolean bPrintAtLeastMajorAndMinor)
bPrintZeroElements - If true than trailing zeroes are printed, otherwise
printed zeroes are not printed.bPrintAtLeastMajorAndMinor - true if major and minor part should always be printed,
independent of their valuenull.@Nonnull @Nonempty public String getAsStringMajorMinor()
null.@Nonnull @Nonempty public String getAsStringMajorMinorMicro()
null.@Nonnull public static Version parse(@Nullable String sVersionString)
sVersionString - the version string to be interpreted as a versionVersion object.IllegalArgumentException - if any of the parameters is < 0@Nonnull public static Version parseDotOnly(@Nullable String sVersionString)
sVersionString - the version string to be interpreted as a versionVersion object.IllegalArgumentException - if any of the parameters is < 0@Nonnull @Deprecated public static Version parse(@Nullable String sVersionString, boolean bOldVersion)
parse(String) and
parseDotOnly(String)sVersionString - the version string to be interpreted as a versionbOldVersion - true to use the old version to parse a string, meaning
splitting only by dot; or false to indicate that the
more complex parsing should be used.Version object.IllegalArgumentException - if any of the parameters is < 0Copyright © 2014–2022 Philip Helger. All rights reserved.