public class Version extends Object implements Comparable<Version>, Serializable
version
the client plugins of JFire and may be used to act
as a version identifier in any project.
The pattern a version String
is:
major
minor
release
[patchLevel
[suffix
]] 1.2.3.test'.
Examples of valid versions are:
1.2.3
1.2.3.4
1.2.3.4.test
1.2.3.t_e!st
Note: This class is immutable!
Modifier and Type | Field and Description |
---|---|
static Version |
MAX_VERSION
The maximum Version possible.
|
static Version |
MIN_VERSION
The minimum Version that can exist.
|
static Pattern |
validityCheck
A regex that is used to check the suffix for valid characters.
|
Constructor and Description |
---|
Version(int major,
int minor,
int release,
int patchLevel) |
Version(int major,
int minor,
int release,
int patchLevel,
String suffix) |
Version(String versionStr)
Creates a new instance from the given
versionStr . |
Modifier and Type | Method and Description |
---|---|
Version |
changeMajor(int major) |
Version |
changeMinor(int minor) |
Version |
changePatchLevel(int patchLevel) |
Version |
changeRelease(int release) |
Version |
changeSuffix(String suffix) |
int |
compareTo(Version other)
Compares this
Version object to another one. |
boolean |
equals(Object other) |
int |
getMajor() |
int |
getMinor() |
int |
getPatchLevel() |
int |
getRelease() |
String |
getSuffix() |
int |
hashCode() |
String |
toString()
Returns the String representation of this version, which is defined as:
major minor
release [patchLevel
[suffix ]] The suffix may consist of 'a-zA-Z0-9#$!_-'. |
public static final Version MIN_VERSION
public static final Version MAX_VERSION
public static Pattern validityCheck
public Version(String versionStr) throws MalformedVersionException
versionStr
.versionStr
- the version encoded as a String.MalformedVersionException
public Version(int major, int minor, int release, int patchLevel)
major
- minor
- release
- patchLevel
- public int getMajor()
public Version changeMajor(int major)
major
- The major with which to create a new Version.public int getMinor()
public Version changeMinor(int minor)
minor
- The minor with which to create a new Version.public int getPatchLevel()
public Version changePatchLevel(int patchLevel)
patchLevel
- The patchLevel with which to create a new Version.public int getRelease()
public Version changeRelease(int release)
release
- The release
with which to create a new Version.release
.public Version changeSuffix(String suffix)
suffix
- The suffix
with which to create a new Version.suffix
.public String toString()
major
minor
release
[patchLevel
[suffix
]] 1.2.3.test'.
public int compareTo(Version other)
Version
object to another one.
A version is considered to be less than another version if its major component is less than the other version's major component, or the major components are equal and its minor component is less than the other version's minor component, or the major and minor components are equal and its release component is less than the other version's release component. The suffix is not relevant for the natural ordering of Versions, though for equality.
Note: Given two version v1,v2
and v1.compareTo(Version v2) = 0
,
this does not imply that v1
and v2
are equal according to equals!
A version is considered to be equal to another version if the
major, minor and micro components are equal and the qualifier component
is equal (see equals(Object)
).
compareTo
in interface Comparable<Version>
other
- The Version
object to be compared.Version
object.Copyright © 2013-2014. All Rights Reserved.