Package io.github.g00fy2.versioncompare
Class Version
java.lang.Object
io.github.g00fy2.versioncompare.Version
- All Implemented Interfaces:
Comparable<Version>
-
Constructor Summary
ConstructorsConstructorDescriptionInitializes a newly created Version object that represents the parsed version information.Initializes a newly created Version object that represents the parsed version information. -
Method Summary
Modifier and TypeMethodDescriptionfinal intfinal booleanlonggetMajor()Returns the major version.longgetMinor()Returns the minor version.@Nullable StringReturns the initial stringlonggetPatch()Returns the patch version.Returns a list with all numeric version parts.@NotNull StringReturns the suffix.final inthashCode()booleanChecks if the Version object is equal or higher thanotherVersion.booleanChecks if the Version object is equal or higher thanotherVersion.booleanChecks if the Version object is equal or higher thanotherVersion.booleanChecks if the Version object is equal or higher thanotherVersion.booleanChecks if the Version object is equal tootherVersion.booleanChecks if the Version object is equal tootherVersion.booleanisHigherThan(Version otherVersion) Checks if the Version object is higher thanotherVersion.booleanisHigherThan(String otherVersion) Checks if the Version object is higher thanotherVersion.booleanisLowerThan(Version otherVersion) Checks if the Version object is lower thanotherVersion.booleanisLowerThan(String otherVersion) Checks if the Version object is lower thanotherVersion.toString()
-
Constructor Details
-
Version
Initializes a newly created Version object that represents the parsed version information. Will have default values ifversionStringcould not get parsed.- Parameters:
versionString- the string representing the version.- See Also:
-
Version
Initializes a newly created Version object that represents the parsed version information. Throws exceptions ifthrowExceptionsistrueandversionStringcould not get parsed.- Parameters:
versionString- the string representing the version.throwExceptions- controls whether invalidversionStringshould cause exceptions.- Throws:
NullPointerException- ifversionStringis null.IllegalArgumentException- ifversionStringdoes not start with a numeric character.- See Also:
-
-
Method Details
-
getMajor
public long getMajor()Returns the major version.- Returns:
- the major version, default 0.
-
getMinor
public long getMinor()Returns the minor version.- Returns:
- the minor version, default 0.
-
getPatch
public long getPatch()Returns the patch version.- Returns:
- the patch version, default 0.
-
getSubversionNumbers
Returns a list with all numeric version parts.- Returns:
- a list with all numeric version parts found, default empty.
-
getSuffix
Returns the suffix.- Returns:
- the suffix (first non-numeric part), default empty.
-
getOriginalString
Returns the initial string- Returns:
- the unmodified initial string.
-
isHigherThan
Checks if the Version object is higher thanotherVersion.- Parameters:
otherVersion- a string representing another version.- Returns:
trueif Version object is higher thanotherVersionorotherVersioncould not get parsed.Falseif the Version is lower or equal.- See Also:
-
isHigherThan
Checks if the Version object is higher thanotherVersion.- Parameters:
otherVersion- a Version object representing another version.- Returns:
trueif Version object is higher thanotherVersionorotherVersioncould not get parsed.Falseif the Version is lower or equal.- See Also:
-
isLowerThan
Checks if the Version object is lower thanotherVersion.- Parameters:
otherVersion- a string representing another version.- Returns:
trueif Version object is lower thanotherVersion.Falseif the Version is higher, equal orotherVersioncould not get parsed.- See Also:
-
isLowerThan
Checks if the Version object is lower thanotherVersion.- Parameters:
otherVersion- a Version object representing another version.- Returns:
trueif Version object is lower thanotherVersion.Falseif the Version is higher, equal orotherVersioncould not get parsed.- See Also:
-
isEqual
Checks if the Version object is equal tootherVersion.- Parameters:
otherVersion- a string representing another version.- Returns:
trueif Version object andotherVersionare logically equal.Falseif the Version is higher, lower orotherVersioncould not get parsed.- See Also:
-
isEqual
Checks if the Version object is equal tootherVersion.- Parameters:
otherVersion- a Version object representing another version.- Returns:
trueif Version object andotherVersionare logically equal.Falseif the Version is higher, lower orotherVersioncould not get parsed.- See Also:
-
isAtLeast
Checks if the Version object is equal or higher thanotherVersion.- Parameters:
otherVersion- a string representing another version.- Returns:
trueif the version is equal or higher thanotherVersion.Falseif the version is lower thanotherVersion.- See Also:
-
isAtLeast
Checks if the Version object is equal or higher thanotherVersion.- Parameters:
otherVersion- a Version object representing another version.- Returns:
trueif the version is equal or higher thanotherVersion.Falseif the version is lower thanotherVersion.- See Also:
-
isAtLeast
Checks if the Version object is equal or higher thanotherVersion.- Parameters:
otherVersion- a string representing another version.ignoreSuffix- controls whether suffixes should be ignored.- Returns:
trueif the version is equal or higher thanotherVersion.Falseif the version is lower thanotherVersion.- See Also:
-
isAtLeast
Checks if the Version object is equal or higher thanotherVersion.- Parameters:
otherVersion- a Version object representing another version.ignoreSuffix- controls whether suffixes should be ignored.- Returns:
trueif the version is equal or higher thanotherVersion.Falseif the version is lower thanotherVersion.- See Also:
-
compareTo
- Specified by:
compareToin interfaceComparable<Version>
-
equals
-
hashCode
public final int hashCode() -
toString
-