Package dev.itsharshxd.zentrix.api
Record Class ApiVersion
java.lang.Object
java.lang.Record
dev.itsharshxd.zentrix.api.ApiVersion
- Record Components:
major- incompatible contract changesminor- additions that keep older addons workingpatch- fixes that change no contract
- All Implemented Interfaces:
Comparable<ApiVersion>
public record ApiVersion(int major, int minor, int patch)
extends Record
implements Comparable<ApiVersion>
A ZentrixAPI contract version,
MAJOR.MINOR.PATCH.
CURRENT is the version of the API classes on the classpath. The running plugin
reports the same value through ZentrixAPI.getAPIVersion(), because Zentrix ships these
classes itself.
Compatibility follows semantic versioning: an addon built for 1.6.0 runs on any
1.x release at or above 1.6.0, and on no 2.x release. Missing minor or
patch numbers read as 0, so "1.6" is 1.6.0.
- Since:
- 1.8.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumHow a required version relates to the installed one. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ApiVersionThe version of the API classes this addon was compiled and is running against. -
Constructor Summary
ConstructorsConstructorDescriptionApiVersion(int major, int minor, int patch) Creates an instance of aApiVersionrecord class. -
Method Summary
Modifier and TypeMethodDescriptionstatic @NotNull ApiVersion.CompatibilityWhether an addon requiringrequiredcan run oncurrent.intcompareTo(@NotNull ApiVersion other) final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.booleanisAtLeast(@NotNull ApiVersion 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 @NotNull Optional<ApiVersion> Reads a version string.intpatch()Returns the value of thepatchrecord component.@NotNull ApiVersion.Compatibilitysupports(@NotNull ApiVersion required) How this installed version relates to a version an addon requires.toString()Returns a string representation of this record class.
-
Field Details
-
CURRENT
The version of the API classes this addon was compiled and is running against.
-
-
Constructor Details
-
Method Details
-
parse
Reads a version string.- Parameters:
version-MAJOR,MAJOR.MINORorMAJOR.MINOR.PATCH; surrounding whitespace and a leadingvare ignored- Returns:
- the version, or empty when the text is not a version
-
check
@NotNull public static @NotNull ApiVersion.Compatibility check(@Nullable @Nullable String required, @Nullable @Nullable String current) Whether an addon requiringrequiredcan run oncurrent.- Parameters:
required- the version an addon needscurrent- the version installed- Returns:
- how the two relate
-
supports
How this installed version relates to a version an addon requires.- Parameters:
required- the version an addon needs- Returns:
ApiVersion.Compatibility.COMPATIBLEwhen an addon requiring it can run here
-
isAtLeast
Whether this version is the same as or newer thanother. -
compareTo
- Specified by:
compareToin interfaceComparable<ApiVersion>
-
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
-