Class Version
java.lang.Object
com.aquima.interactions.foundation.Version
- All Implemented Interfaces:
Serializable
,Comparable<Version>
- Direct Known Subclasses:
CodeVersion
Simple class that holds a version identifier.
A version may consist three separate parts:
- A major version Major version numbers are usually increased when substantial new functionality is added, or when a new version is not backward compatible with the previous.
- A minor version The minor version is used to identify the revision of a certain product. Usually the minor version get updated when new Functionality is added, but the old functionality remains compatible with the previous version.
- The patch version The patch version may hold any string, and is usually used to indicate a trivial change to the previous version. Patch versions get updated when small changes or bug fixes occur that have no impact on compatibility.
- Since:
- 5.0
- Author:
- o.kerpershoek
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
boolean
protected String
formatPatch
(String patch) getLabel()
This method returns the (optional) label of the version.int
getMajor()
This method returns the major number of the version.int
getMinor()
This method returns the minor number of the version.getPatch()
This method returns the patch identifier of the version.The getString method will print the version in a nice readable format.int
hashCode()
toString()
static Version
This method will try to convert the passed version string to a Version object.static Version
This method will try to convert the passed version string to a Version object.
-
Field Details
-
ANY
-
DEFAULT
-
-
Constructor Details
-
Version
Constructs a version object from a major, minor and patch identifier. The patch identifier is optional, and as such the value null is allowed.- Parameters:
major
- The major version number.minor
- The minor version number.patch
- Identifier of the patch for the specified major and minor version.label
- Optional label for the version which may be used as display text.
-
-
Method Details
-
valueOf
This method will try to convert the passed version string to a Version object.There are three possible results of this method:
- A null value when the passed string was null or empty.
- An IllegalArgumentExceptionwhen the passed string does not conform to the version syntax.
- A valid Version object containing the version string information.
- Parameters:
strVersion
- string containing the version information.- Returns:
- A valid Version object, or null when the passed version string was empty.
-
valueOf
This method will try to convert the passed version string to a Version object.There are three possible results of this method:
- A null value when the passed string was null or empty.
- An IllegalArgumentExceptionwhen the passed string does not conform to the version syntax.
- A valid Version object containing the version string information.
- Parameters:
strVersion
- string containing the version information.label
- Optional label for the version which may be used as display text.- Returns:
- A valid Version object, or null when the passed version string was empty.
-
formatPatch
-
getMajor
public int getMajor()This method returns the major number of the version.- Returns:
- the major number of the version.
-
getMinor
public int getMinor()This method returns the minor number of the version.- Returns:
- the minor number of the version.
-
getPatch
This method returns the patch identifier of the version.- Returns:
- the patch identifier of the version.
-
getLabel
This method returns the (optional) label of the version. A label may be used as a display value for the version. The label could for instance contain a name instead of the (cryptic) version number.- Returns:
- The label for the version, or null if no label was defined.
-
hashCode
public int hashCode() -
equals
-
compareTo
- Specified by:
compareTo
in interfaceComparable<Version>
-
toString
-
getString
The getString method will print the version in a nice readable format. The major and minor version are always printed using a dot as seperator. When the patch number is available, it will be appended. Depending on the format of the patch, an additional dot may be added between the minor version and the patch version.Examples:
- 5.0
- 1.0-b
- 2.3.12
- 5.0.1-alpha
- Returns:
- String containing a formatted version
-