Record Class Version
java.lang.Object
java.lang.Record
fr.robie.machineengine.api.version.Version
- All Implemented Interfaces:
Comparable<Version>
public record Version(int major, int minor, int patch, @Nullable String qualifier)
extends Record
implements Comparable<Version>
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription@NotNull Versionbase()Returns this version without its qualifier.intfinal booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.booleanReturns whether this version is strictly greater thanother.booleanReturns whether this version is greater than or equal toother.booleanReturns whether this version is less than or equal toother.booleanReturns whether this version is strictly less thanother.booleanReturns whether this version has a qualifier.booleanisStable()Returns whether this version is a stable release.intmajor()Returns the value of themajorrecord component.intminor()Returns the value of theminorrecord component.static @NotNull Versionof(int major, int minor, int patch) Creates a version without a qualifier.static @NotNull VersionCreates a version with a qualifier.static @NotNull VersionParses a version string.intpatch()Returns the value of thepatchrecord component.@Nullable StringReturns the value of thequalifierrecord component.@NotNull StringtoString()Returns the version in canonical form.
-
Constructor Details
-
Version
Creates an instance of aVersionrecord class.- Parameters:
major- the value for themajorrecord componentminor- the value for theminorrecord componentpatch- the value for thepatchrecord componentqualifier- the value for thequalifierrecord component
-
-
Method Details
-
of
Creates a version without a qualifier. -
of
-
parse
Parses a version string.- Parameters:
text- version text- Returns:
- parsed version
- Throws:
IllegalArgumentException- if the text is not a valid version
-
base
Returns this version without its qualifier. -
isAtLeast
Returns whether this version is greater than or equal toother. -
isAtMost
Returns whether this version is less than or equal toother. -
isAfter
Returns whether this version is strictly greater thanother. -
isBefore
Returns whether this version is strictly less thanother. -
isQualified
public boolean isQualified()Returns whether this version has a qualifier. -
isStable
public boolean isStable()Returns whether this version is a stable release. -
compareTo
- Specified by:
compareToin interfaceComparable<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
public int major()Returns the value of themajorrecord component.- Returns:
- the value of the
majorrecord component
-
minor
public int minor()Returns the value of theminorrecord component.- Returns:
- the value of the
minorrecord component
-
patch
public int patch()Returns the value of thepatchrecord component.- Returns:
- the value of the
patchrecord component
-
qualifier
Returns the value of thequalifierrecord component.- Returns:
- the value of the
qualifierrecord component
-