Record Class GitVersion
java.lang.Object
java.lang.Record
io.github.jbastgen.stemma.git.cli.GitVersion
- All Implemented Interfaces:
Comparable<GitVersion>
public record GitVersion(int major, int minor, int patch)
extends Record
implements Comparable<GitVersion>
A git version such as
2.43.0. Vendor suffixes ("windows.1", "Apple Git-145") are ignored.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final GitVersionOldest git version the CLI backend supports. -
Constructor Summary
ConstructorsConstructorDescriptionGitVersion(int major, int minor, int patch) Creates an instance of aGitVersionrecord class. -
Method Summary
Modifier and TypeMethodDescriptionintcompareTo(GitVersion other) final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.booleanisAtLeast(GitVersion other) Whether this version is the same as or newer thanother.intmajor()Returns the value of themajorrecord component.intminor()Returns the value of theminorrecord component.static Optional<GitVersion> Parses the output ofgit --version, e.g.intpatch()Returns the value of thepatchrecord component.toString()Returns a string representation of this record class.
-
Field Details
-
MINIMUM
Oldest git version the CLI backend supports.
-
-
Constructor Details
-
GitVersion
public GitVersion(int major, int minor, int patch) Creates an instance of aGitVersionrecord class.- Parameters:
major- the value for themajorrecord componentminor- the value for theminorrecord componentpatch- the value for thepatchrecord component
-
-
Method Details
-
parse
Parses the output ofgit --version, e.g."git version 2.39.3 (Apple Git-145)". -
isAtLeast
Whether this version is the same as or newer thanother. -
compareTo
- Specified by:
compareToin interfaceComparable<GitVersion>
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
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 '=='. -
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
-