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 aSoftwareVersionrecord class. -
Method Summary
Modifier and TypeMethodDescriptionintcompareTo(SoftwareVersion other) Behaves similarly toisGreaterThan(SoftwareVersion)except returns0for equal instances.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.booleanisGreaterThan(SoftwareVersion other) intmajor()Returns the value of themajorrecord component.intminor()Returns the value of theminorrecord component.static SoftwareVersionintpatch()Returns the value of thepatchrecord component.Returns the value of thequalifierrecord 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 aSoftwareVersionrecord class.
-
-
Method Details
-
parse
- Parameters:
version- Version string.- Throws:
IllegalArgumentException- if the string cannot be parsed.
-
compareTo
Behaves similarly toisGreaterThan(SoftwareVersion)except returns0for equal instances.- Specified by:
compareToin 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 thecomparemethod from their corresponding wrapper classes. -
major
-
minor
-
patch
-
qualifier
-