Class ApiVersion
- All Implemented Interfaces:
Comparable<ApiVersion>
CURRENT is the single source of the runtime's API version. The build stamps the same value into
the shared-lib jar manifest as "PrivBot-Api-Version", from the privbot.api.version Maven
property, through the filtered resource privbot/api/api-version.properties. A plugin records the
version it compiled against in its own manifest as "Plugin-Api-Version".
Compatibility (isCompatible(String)): same major, and the plugin's minor is not newer than the
runtime's. Patch levels and pre-release qualifiers never matter. A plugin with no
"Plugin-Api-Version" is legacy: check(String, String) allows it only on the
"first-party" channel. The policy behind the rule is in the SDK docs, Versioning.
- Since:
- 1.0.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumOutcome ofcheck(java.lang.String, java.lang.String).static final classA load decision with a message fit to show the user. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe API version this runtime provides, for example"1.0.0".static final StringThe only hub channel on which a legacy plugin (no "Plugin-Api-Version") may load.static final Stringshared-lib (runtime) jar manifest attribute that carriesCURRENT.static final StringPlugin jar manifest attribute that carries the API version the plugin compiled against. -
Method Summary
Modifier and TypeMethodDescriptionbooleancanRun(ApiVersion plugin) True when this runtime version can run a plugin built againstplugin.static ApiVersion.VerdictThe load decision for a plugin on this runtime: compatibility plus the legacy rule (a plugin without an API version loads only from the "first-party" channel).static ApiVersion.Verdictcheck(String, String)against an explicit runtime version.intstatic ApiVersioncurrent()CURRENT, parsed.booleaninthashCode()static booleanisCompatible(String pluginApiVersion) True when a plugin built againstpluginApiVersionmay run on this runtime (CURRENT): same major and plugin minor <= runtime minor.static booleanisCompatible(String pluginApiVersion, String runtimeApiVersion) isCompatible(String)against an explicit runtime version.static booleanTrue when a plugin declares no API version (null or blank "Plugin-Api-Version").intmajor()intminor()static ApiVersionParsesMAJOR[.MINOR[.PATCH]][-qualifier][+build], for example1.2.0,1.2or1.3.0-SNAPSHOT.intpatch()Pre-release qualifier such asSNAPSHOT, or null.toString()CanonicalMAJOR.MINOR.PATCH[-qualifier].static Optional<ApiVersion> parse(java.lang.String), or empty for a null, blank or malformed value.
-
Field Details
-
MANIFEST_ATTRIBUTE
-
PLUGIN_MANIFEST_ATTRIBUTE
Plugin jar manifest attribute that carries the API version the plugin compiled against.- See Also:
-
FIRST_PARTY_CHANNEL
The only hub channel on which a legacy plugin (no "Plugin-Api-Version") may load.- See Also:
-
CURRENT
The API version this runtime provides, for example"1.0.0".Deliberately not a compile-time constant: a plugin that reads it gets the version of the PrivBot it runs on, not the one it was compiled against (that one is in its own manifest).
-
-
Method Details
-
current
CURRENT, parsed. -
parse
ParsesMAJOR[.MINOR[.PATCH]][-qualifier][+build], for example1.2.0,1.2or1.3.0-SNAPSHOT. Surrounding whitespace is ignored; build metadata is dropped.- Throws:
IllegalArgumentException- whentextis null, blank or not a version
-
tryParse
parse(java.lang.String), or empty for a null, blank or malformed value. -
isLegacy
True when a plugin declares no API version (null or blank "Plugin-Api-Version"). -
isCompatible
True when a plugin built againstpluginApiVersionmay run on this runtime (CURRENT): same major and plugin minor <= runtime minor.False for a legacy (blank) or malformed value. Load decisions should use
check(String, String), which also applies the legacy rule and explains a refusal. -
isCompatible
isCompatible(String)against an explicit runtime version. -
canRun
True when this runtime version can run a plugin built againstplugin. -
check
The load decision for a plugin on this runtime: compatibility plus the legacy rule (a plugin without an API version loads only from the "first-party" channel).- Parameters:
pluginApiVersion- the plugin's "Plugin-Api-Version", or null when absentchannel- the hub channel the plugin came from (first-party,private,community,local); null counts as not first-party
-
check
public static ApiVersion.Verdict check(String pluginApiVersion, String channel, String runtimeApiVersion) check(String, String)against an explicit runtime version. -
major
public int major() -
minor
public int minor() -
patch
public int patch() -
qualifier
Pre-release qualifier such asSNAPSHOT, or null. Ignored by every compatibility rule. -
compareTo
- Specified by:
compareToin interfaceComparable<ApiVersion>
-
equals
-
hashCode
-
toString
-