Record Class SoftwareVersion
java.lang.Object
java.lang.Record
is.galia.util.SoftwareVersion
- Record Components:
major
- Major version.minor
- Minor version.patch
- Patch version.qualifier
- String following the version, such asrc1
,-SNAPSHOT
, etc.
- All Implemented Interfaces:
Comparable<SoftwareVersion>
public record SoftwareVersion(int major, int minor, int patch, String qualifier)
extends Record
implements Comparable<SoftwareVersion>
Software version supporting n.n.n-qualifier syntax.
-
Constructor Summary
ConstructorsConstructorDescriptionSoftwareVersion
(int major) Creates an n.0 instance.SoftwareVersion
(int major, int minor) Creates an n.n instance.SoftwareVersion
(int major, int minor, int patch) Creates an n.n.n instance.SoftwareVersion
(int major, int minor, int patch, String qualifier) Creates an instance of aSoftwareVersion
record class. -
Method Summary
Modifier and TypeMethodDescriptionint
compareTo
(SoftwareVersion other) Behaves similarly toisGreaterThan(SoftwareVersion)
except returns0
for equal instances.final boolean
Indicates whether some other object is "equal to" this one.final int
hashCode()
Returns a hash code value for this object.boolean
isGreaterThan
(SoftwareVersion other) int
major()
Returns the value of themajor
record component.int
minor()
Returns the value of theminor
record component.static SoftwareVersion
int
patch()
Returns the value of thepatch
record component.Returns the value of thequalifier
record component.toString()
Returns a string representation of this record class.
-
Constructor Details
-
SoftwareVersion
public SoftwareVersion(int major) Creates an n.0 instance.- Parameters:
major
- Major version.
-
SoftwareVersion
public SoftwareVersion(int major, int minor) Creates an n.n instance.- Parameters:
major
- Major version.minor
- Minor version.
-
SoftwareVersion
public SoftwareVersion(int major, int minor, int patch) Creates an n.n.n instance.- Parameters:
major
- Major version.minor
- Minor version.patch
- Patch version.
-
SoftwareVersion
Creates an instance of aSoftwareVersion
record class.
-
-
Method Details
-
parse
- Parameters:
version
- Version string.- Throws:
IllegalArgumentException
- if the string cannot be parsed.
-
compareTo
Behaves similarly toisGreaterThan(SoftwareVersion)
except returns0
for equal instances.- Specified by:
compareTo
in interfaceComparable<SoftwareVersion>
- Parameters:
other
- The object to be compared.- Returns:
- Whether the instance is greater than, equal to, or less than the given instance.
-
isGreaterThan
- Parameters:
other
- Instance to compare against.- Returns:
- Whether the instance is greater than the given version.
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object)
; primitive components are compared with thecompare
method from their corresponding wrapper classes. -
major
-
minor
-
patch
-
qualifier
-