Record Class SemanticVersion
java.lang.Object
java.lang.Record
io.github.joke.conventionalversion.calc.SemanticVersion
- All Implemented Interfaces:
Serializable, Comparable<SemanticVersion>
public record SemanticVersion(int major, int minor, int patch)
extends Record
implements Comparable<SemanticVersion>, Serializable
A
major.minor.patch version, without pre-release or build metadata.- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionSemanticVersion(int major, int minor, int patch) Creates an instance of aSemanticVersionrecord class. -
Method Summary
Modifier and TypeMethodDescriptionintcompareTo(SemanticVersion other) final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.booleanWhether this version is below1.0.0, which is the condition both pre-major policies are gated on.intmajor()Returns the value of themajorrecord component.intminor()Returns the value of theminorrecord component.static Optional<SemanticVersion> Parses1.2.3, returning empty when the text is not exactly three numeric parts.intpatch()Returns the value of thepatchrecord component.toString()Returns a string representation of this record class.
-
Constructor Details
-
SemanticVersion
public SemanticVersion(int major, int minor, int patch) Creates an instance of aSemanticVersionrecord class.- Parameters:
major- the value for themajorrecord componentminor- the value for theminorrecord componentpatch- the value for thepatchrecord component
-
-
Method Details
-
parse
Parses1.2.3, returning empty when the text is not exactly three numeric parts. -
isPreMajor
public boolean isPreMajor()Whether this version is below1.0.0, which is the condition both pre-major policies are gated on. -
bumpMajor
-
bumpMinor
-
bumpPatch
-
compareTo
- Specified by:
compareToin interfaceComparable<SemanticVersion>
-
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. All components in this record class 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
-