public class Version extends java.lang.Object implements java.lang.Comparable<Version>, java.io.Serializable
Version identifiers have three components:
Two Versions are considered equal if all components are equal.
Constructor and Description |
---|
Version(int major,
int minor,
int build)
Instantiate a new Version from its component.
The standard format is Major.Minor.Build.Metamodel. |
Version(java.lang.String versionString)
Instantiate a new Version from a String.
|
Modifier and Type | Method and Description |
---|---|
int |
compareTo(Version other) |
boolean |
equals(java.lang.Object anObject)
Compares this Version to the specified object.
|
int |
getBuildVersion()
Get the build number of this version
|
int |
getMajorVersion()
Get the major number of this version.
|
int |
getMinorVersion()
Get the minor number of this version.
|
int |
hashCode() |
boolean |
isNewerBuildOf(Version other)
Tells whether the only difference between this version and the other
is that this version build is newer than the other.
|
boolean |
isNewerOrSameThan(Version other)
Check if this Version is same or newer than the given Version.
|
boolean |
isNewerThan(Version other)
Check if this Version is strictly newer than the given Version.
|
boolean |
isOlderOrSameThan(Version other)
Check if this Version is same or older than the given Version.
|
boolean |
isOlderThan(Version other)
Check if this Version is strictly older than the given Version.
|
java.lang.String |
toString()
Provides a formatted string representation of the version.
|
java.lang.String |
toString(java.lang.String format)
Provides a formatted string representation of the version.
|
Version |
withBuild(int newBuild)
Return a copy of this version with the build number modified.
|
Version |
withoutBuild()
Return a copy of this version with the build number zeroed .
|
public Version(int major, int minor, int build)
major
- the first component of the version.minor
- the second component of the version.build
- the third component of the version.public Version(java.lang.String versionString) throws java.lang.NumberFormatException
versionString
- The String to parse to create the version.java.lang.NumberFormatException
- thrown when the parameter doesn't have a valid format.public int compareTo(Version other)
compareTo
in interface java.lang.Comparable<Version>
public boolean equals(java.lang.Object anObject)
The result is true if and only if the argument is not null and is a Version object that represents the same version object as this object.
Two Versions are considered equal if the only difference is one of their metamodel version being zero.
equals
in class java.lang.Object
anObject
- The object to compare this Version against.public int getBuildVersion()
public int getMajorVersion()
public int getMinorVersion()
public int hashCode()
hashCode
in class java.lang.Object
public boolean isNewerBuildOf(Version other)
other
- another version to compare to.public boolean isNewerOrSameThan(Version other)
other
- the Version object that must be compared to this Version.public boolean isNewerThan(Version other)
other
- the Version object that must be compared to this Version.public boolean isOlderOrSameThan(Version other)
other
- the Version object that must be compared to this Version.public boolean isOlderThan(Version other)
other
- the Version object that must be compared to this Version.public java.lang.String toString()
The format is: V.R.CC where:
toString
in class java.lang.Object
public java.lang.String toString(java.lang.String format)
format
- The format is: VRC where:
public Version withBuild(int newBuild)
newBuild
- the new build version.public Version withoutBuild()