Package io.gdcc.spi.meta.annotations
Annotation Interface PluginContract
Declares a versioned plugin contract interface.
A plugin contract defines either a directly loadable plugin kind
(PluginContract.Role.BASE) or an additional, non-loadable capability
(PluginContract.Role.CAPABILITY).
The annotated type must be an interface extending Plugin
and must declare a compile-time constant primitive int API_LEVEL field.
General contract rules:
- Plugin contracts may only be declared on interfaces.
- Plugin contracts must extend
Plugin. - Plugin contracts may not extend other plugin contracts. (One exception, see below.)
- A plugin implementation may implement exactly one
base contract.
Base contracts are used as the unique service-loading identity of a plugin. Capability contracts are never loaded directly; they add optional functionality and are discovered through generated plugin metadata.
Capability rules:
- A capability contract must declare
requires(). - A capability must require exactly one base contract.
- A capability may extend the required base contract to provide default implementations.
- For now, requiring or extending another capability is not supported.
- A plugin implementing a capability must also implement its required base contract.
- Implementation Note:
- Example base contract:
Example capability contract:@PluginContract(role = PluginContract.Role.BASE) public interface FooBar extends Plugin { int API_LEVEL = 1; }@PluginContract( role = PluginContract.Role.CAPABILITY, requires = { FooBar.class } ) public interface BarBeque extends Plugin { int API_LEVEL = 1; default String getMediaType() { return "application/bbq"; } }
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumDistinguishes directly loadable base contracts from additional capability contracts. -
Required Element Summary
Required ElementsModifier and TypeRequired ElementDescriptionDeclares whether this contract is a directly loadable base contract or an additional capability contract. -
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionCore provider contracts required by this plugin contract.Other plugin contracts that must also be implemented when this contract is implemented.
-
Element Details
-
role
PluginContract.Role roleDeclares whether this contract is a directly loadable base contract or an additional capability contract.
-
-
-
requires
Other plugin contracts that must also be implemented when this contract is implemented.For
capabilities, this must currently contain exactly one requiredbase contract. Capabilities are not directly loadable and therefore must always be paired with their base contract.- Default:
- {}
-
providers
RequiredProvider[] providersCore provider contracts required by this plugin contract.- Default:
- {}
-