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(@Nullable Integer major, @Nullable Integer minor, @Nullable Integer patch, @Nullable Version.Qualifier qualifier) -
Method Summary
Modifier and TypeMethodDescriptionintbooleanformat(Version.Format format) Format this version to the specifiedVersion.Format.@Nullable IntegergetMajor()@Nullable IntegergetMinor()@Nullable IntegergetPatch()@Nullable Version.QualifierinthashCode()booleanSpecify if this version is a general availability (GA) release, that is a version with no qualifier or with the specialRELEASEqualifier.static VersionParse the string representation of aVersion.static @Nullable VersionParse safely the specified string representation of aVersion.toString()
-
Constructor Details
-
Version
public Version(@Nullable Integer major, @Nullable Integer minor, @Nullable Integer patch, @Nullable Version.Qualifier qualifier)
-
-
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
-
isGeneralAvailability
public boolean isGeneralAvailability()Specify if this version is a general availability (GA) release, that is a version with no qualifier or with the specialRELEASEqualifier.- Returns:
trueif this version is a GA release
-
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
-
compareTo
- Specified by:
compareToin interfaceComparable<Version>
-
equals
-
hashCode
-
toString
-