Class Version
java.lang.Object
org.codehaus.gmavenplus.model.internal.Version
- All Implemented Interfaces:
Comparable<Version>
Container for Version information in the form of major.minor.revision-tag.
- Since:
- 1.0-beta-1
- Author:
- Jason Dillon, Keegan Witt
-
Constructor Summary
ConstructorDescriptionVersion
(int newMajor) Constructs a new Version object with the specified parameters.Version
(int newMajor, int newMinor) Constructs a new Version object with the specified parameters.Version
(int newMajor, int newMinor, int newRevision) Constructs a new Version object with the specified parameters.Constructs a new version object with the specified parameters. -
Method Summary
Modifier and TypeMethodDescriptionfinal int
Compares two versions objects.final int
Compares two versions objects.final boolean
Determines whether the specified object is equal to this object.int
getMajor()
Gets the version major number.int
getMinor()
Gets the version minor number.int
Gets the version revision number.getTag()
Gets the version tag string.final int
hashCode()
Returns a hash code for this object.static Version
parseFromString
(String version) Parses a new Version object from a string.setMajor
(int newMajor) Sets the version major number.setMinor
(int newMinor) Sets the version minor number.setRevision
(int newRevision) Sets the version revision number.Sets the version tag string.final String
toString()
Returns a String representation of this object.
-
Constructor Details
-
Version
Constructs a new version object with the specified parameters.- Parameters:
newMajor
- The version major numbernewMinor
- The version minor numbernewRevision
- The version revision numbernewTag
- The version tag string
-
Version
public Version(int newMajor, int newMinor, int newRevision) Constructs a new Version object with the specified parameters.- Parameters:
newMajor
- The version major numbernewMinor
- The version minor numbernewRevision
- The version revision number
-
Version
public Version(int newMajor, int newMinor) Constructs a new Version object with the specified parameters.- Parameters:
newMajor
- The version major numbernewMinor
- The version minor number
-
Version
public Version(int newMajor) Constructs a new Version object with the specified parameters.- Parameters:
newMajor
- The version major number
-
-
Method Details
-
parseFromString
Parses a new Version object from a string.- Parameters:
version
- The version string to parse- Returns:
- The version parsed from the string
-
hashCode
public final int hashCode()Returns a hash code for this object. -
equals
Determines whether the specified object is equal to this object. -
toString
Returns a String representation of this object. -
compareTo
Compares two versions objects. Note that if the major, minor, and revision are all the same, tags are compared withString.compareTo()
. Having no tag is considered a newer version than a version with a tag.- Specified by:
compareTo
in interfaceComparable<Version>
- Parameters:
version
- The version to compare this version to- Returns:
0
if the version is equal to this version,1
if the version is greater than this version, or-1
if the version is lower than this version.
-
compareTo
Compares two versions objects. Note that if the major, minor, and revision are all the same, tags are compared withString.compareTo()
.- Parameters:
version
- The version to compare this version tonoTagsAreNewer
- Whether versions with no tag are considered newer than those that have tags- Returns:
0
if the version is equal to this version,1
if the version is greater than this version, or-1
if the version is lower than this version.
-
getMajor
public int getMajor()Gets the version major number.- Returns:
- The major version number
-
setMajor
Sets the version major number.- Parameters:
newMajor
- The major version number to set- Returns:
- This object (for fluent invocation)
-
getMinor
public int getMinor()Gets the version minor number.- Returns:
- The version minor number
-
setMinor
Sets the version minor number.- Parameters:
newMinor
- The version minor number to set- Returns:
- This object (for fluent invocation)
-
getRevision
public int getRevision()Gets the version revision number.- Returns:
- The version revision number
-
setRevision
Sets the version revision number.- Parameters:
newRevision
- The revision number to set- Returns:
- This object (for fluent invocation)
-
getTag
Gets the version tag string.- Returns:
- The version tag string
-
setTag
Sets the version tag string.- Parameters:
newTag
- The version tag string to set- Returns:
- This object (for fluent invocation)
-