Class Version
java.lang.Object
io.spring.initializr.generator.version.Version
- All Implemented Interfaces:
Serializable,Comparable<Version>
Define a version. A typical version is represented as
MAJOR.MINOR.PATCH[QUALIFIER] where the qualifier is optional and can have an
extra version.
For example: 1.2.0.RC1 is the first release candidate of 1.2.0 and
1.5.0-M4 is the fourth milestone of 1.5.0. The special RELEASE
qualifier indicates a final release (a.k.a. GA).
Two formats are currently supported, Version.Format.V1 that uses a dot to separate the
qualifier from the version itself and Version.Format.V2 that is SemVer compliant (and
therefore uses a dash to separate the qualifier).
The main purpose of parsing a version is to compare it with another version.
- Author:
- Stephane Nicoll
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumDefine the supported version format.static classA version qualifier. -
Constructor Summary
ConstructorsConstructorDescriptionVersion(Integer major, Integer minor, Integer patch, Version.Qualifier qualifier) -
Method Summary
Modifier and TypeMethodDescriptionintbooleanformat(Version.Format format) Format this version to the specifiedVersion.Format.getMajor()getMinor()getPatch()inthashCode()static VersionParse the string representation of aVersion.static VersionParse safely the specified string representation of aVersion.toString()
-
Constructor Details
-
Version
-
-
Method Details
-
format
Format this version to the specifiedVersion.Format.- Parameters:
format- the format to use- Returns:
- a version compliant with the specified format.
-
getMajor
-
getMinor
-
getPatch
-
getQualifier
-
getFormat
-
parse
Parse the string representation of aVersion. Throws anInvalidVersionExceptionif the version could not be parsed.- Parameters:
text- the version text- Returns:
- a Version instance for the specified version text
- Throws:
InvalidVersionException- if the version text could not be parsed- See Also:
-
safeParse
Parse safely the specified string representation of aVersion.Return
nullif the text represents an invalid version.- Parameters:
text- the version text- Returns:
- a Version instance for the specified version text
- See Also:
-
compareTo
- Specified by:
compareToin interfaceComparable<Version>
-
equals
-
hashCode
public int hashCode() -
toString
-