Package io.github.g00fy2.versioncompare
Class Version
java.lang.Object
io.github.g00fy2.versioncompare.Version
- All Implemented Interfaces:
Comparable<Version>
-
Constructor Summary
ConstructorDescriptionInitializes 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 int
final boolean
long
getMajor()
Returns the major version.long
getMinor()
Returns the minor version.@Nullable String
Returns the initial stringlong
getPatch()
Returns the patch version.Returns a list with all numeric version parts.@NotNull String
Returns the suffix.final int
hashCode()
boolean
Checks if the Version object is equal or higher thanotherVersion
.boolean
Checks if the Version object is equal or higher thanotherVersion
.boolean
Checks if the Version object is equal or higher thanotherVersion
.boolean
Checks if the Version object is equal or higher thanotherVersion
.boolean
Checks if the Version object is equal tootherVersion
.boolean
Checks if the Version object is equal tootherVersion
.boolean
isHigherThan
(Version otherVersion) Checks if the Version object is higher thanotherVersion
.boolean
isHigherThan
(String otherVersion) Checks if the Version object is higher thanotherVersion
.boolean
isLowerThan
(Version otherVersion) Checks if the Version object is lower thanotherVersion
.boolean
isLowerThan
(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 ifversionString
could 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 ifthrowExceptions
istrue
andversionString
could not get parsed.- Parameters:
versionString
- the string representing the version.throwExceptions
- controls whether invalidversionString
should cause exceptions.- Throws:
NullPointerException
- ifversionString
is null.IllegalArgumentException
- ifversionString
does 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:
true
if Version object is higher thanotherVersion
orotherVersion
could not get parsed.False
if 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:
true
if Version object is higher thanotherVersion
orotherVersion
could not get parsed.False
if 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:
true
if Version object is lower thanotherVersion
.False
if the Version is higher, equal orotherVersion
could not get parsed.- See Also:
-
isLowerThan
Checks if the Version object is lower thanotherVersion
.- Parameters:
otherVersion
- a Version object representing another version.- Returns:
true
if Version object is lower thanotherVersion
.False
if the Version is higher, equal orotherVersion
could not get parsed.- See Also:
-
isEqual
Checks if the Version object is equal tootherVersion
.- Parameters:
otherVersion
- a string representing another version.- Returns:
true
if Version object andotherVersion
are logically equal.False
if the Version is higher, lower orotherVersion
could not get parsed.- See Also:
-
isEqual
Checks if the Version object is equal tootherVersion
.- Parameters:
otherVersion
- a Version object representing another version.- Returns:
true
if Version object andotherVersion
are logically equal.False
if the Version is higher, lower orotherVersion
could not get parsed.- See Also:
-
isAtLeast
Checks if the Version object is equal or higher thanotherVersion
.- Parameters:
otherVersion
- a string representing another version.- Returns:
true
if the version is equal or higher thanotherVersion
.False
if 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:
true
if the version is equal or higher thanotherVersion
.False
if 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:
true
if the version is equal or higher thanotherVersion
.False
if 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:
true
if the version is equal or higher thanotherVersion
.False
if the version is lower thanotherVersion
.- See Also:
-
compareTo
- Specified by:
compareTo
in interfaceComparable<Version>
-
equals
-
hashCode
public final int hashCode() -
toString
-