Record Class SemVer
java.lang.Object
java.lang.Record
io.github.chrimle.classforge.semver.SemVer
- Record Components:
major
- version.minor
- version.patch
- version.
Represents a Semantic Version (SemVer).
- Since:
- 0.3.0
- Author:
- Chrimle
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal boolean
Indicates whether some other object is "equal to" this one.final int
hashCode()
Returns a hash code value for this object.Creates a newSemVer
with themajor
-version incremented.Creates a newSemVer
with theminor
-version incremented.Creates a newSemVer
with thepatch
-version incremented.incrementVersion
(SemVer.Change change) Creates a newSemVer
with the corresponding version incremented.int
major()
Returns the value of themajor
record component.int
minor()
Returns the value of theminor
record component.int
patch()
Returns the value of thepatch
record component.Returns thisSemVer
as aString
in the format:v{major}.{minor}.{patch}
- where trailing zero sub-versions are omitted.toString()
-
Constructor Details
-
SemVer
public SemVer(int major, int minor, int patch) Constructs a validSemVer
instance.- Parameters:
major
- version.minor
- version.patch
- version.- Throws:
IllegalArgumentException
- ifmajor
is less than0
.IllegalArgumentException
- ifminor
is less than0
.IllegalArgumentException
- ifpatch
is less than0
.- Since:
- 0.3.0
-
-
Method Details
-
incrementVersion
Creates a newSemVer
with the corresponding version incremented.- Parameters:
change
- for determining the newSemVer
.- Returns:
- the new
SemVer
. - Throws:
IllegalArgumentException
- ifchange
isnull
.- Since:
- 0.3.0
-
incrementMajor
Creates a newSemVer
with themajor
-version incremented.- Returns:
- the new
SemVer
. - Since:
- 0.3.0
-
incrementMinor
Creates a newSemVer
with theminor
-version incremented.- Returns:
- the new
SemVer
. - Since:
- 0.3.0
-
incrementPatch
Creates a newSemVer
with thepatch
-version incremented.- Returns:
- the new
SemVer
. - Since:
- 0.3.0
-
toString
-
toShortVersionString
Returns thisSemVer
as aString
in the format:v{major}.{minor}.{patch}
- where trailing zero sub-versions are omitted.Examples:
1.0.0
returns"v1"
1.2.0
returns"v1.2"
1.2.3
returns"v1.2.3"
- Returns:
- the formatted
String
. - Since:
- 0.4.0
-
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 themajor
record component.- Returns:
- the value of the
major
record component
-
minor
public int minor()Returns the value of theminor
record component.- Returns:
- the value of the
minor
record component
-
patch
public int patch()Returns the value of thepatch
record component.- Returns:
- the value of the
patch
record component
-