Package com.cleanroommc.versioning
Record Class SemanticVersion
java.lang.Object
java.lang.Record
com.cleanroommc.versioning.SemanticVersion
- Record Components:
major- major componentminor- minor componentpatch- patch component
- All Implemented Interfaces:
Serializable,Comparable<SemanticVersion>
public record SemanticVersion(long major, long minor, long patch)
extends Record
implements Comparable<SemanticVersion>, Serializable
A strict numeric semantic version used by release tags.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final SemanticVersionThe baseline used before the first tag exists. -
Constructor Summary
ConstructorsConstructorDescriptionSemanticVersion(long major, long minor, long 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.static booleanlongmajor()Returns the value of themajorrecord component.longminor()Returns the value of theminorrecord component.static SemanticVersionParses a strict numeric version.static SemanticVersionparseTarget(String value) Parses the version a development branch leads to.longpatch()Returns the value of thepatchrecord component.toString()Returns a string representation of this record class.
-
Field Details
-
INITIAL
The baseline used before the first tag exists.
-
-
Constructor Details
-
Method Details
-
parse
Parses a strict numeric version.- Parameters:
value- the text to parse- Returns:
- the parsed version
- Throws:
IllegalArgumentException- if the text is not<major>.<minor>.<patch>, with an optionalvprefix
-
parseTarget
Parses the version a development branch leads to. The patch component may be omitted and has to be zero when present, because a patch is a fix on top of a release rather than something a line is developed towards.- Parameters:
value- the text to parse- Returns:
- the parsed target
- Throws:
IllegalArgumentException- if the text names no target, or names one carrying a patch
-
isValid
- Parameters:
value- the text to test- Returns:
- whether the text is a strict numeric version, with or without a
vprefix
-
nextPatch
- Returns:
- the start of the next patch line
-
compareTo
- Specified by:
compareToin interfaceComparable<SemanticVersion>
-
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 long major()Returns the value of themajorrecord component.- Returns:
- the value of the
majorrecord component
-
minor
public long minor()Returns the value of theminorrecord component.- Returns:
- the value of the
minorrecord component
-
patch
public long patch()Returns the value of thepatchrecord component.- Returns:
- the value of the
patchrecord component
-