Package io.gdcc.spi.meta.descriptor
Class DescriptorFormat
java.lang.Object
io.gdcc.spi.meta.descriptor.DescriptorFormat
Defines constants for the format and structure of plugin plugin files.
These descriptors provide metadata about plugins, including their
implementation class, type, contracts, and required providers.
-
- DESCRIPTOR_DIRECTORY: Specifies the directory where plugin plugin files are located.
- PLUGIN_CLASS_FIELD: Defines the key used to identify the plugin's implementation class.
- PLUGIN_KIND_FIELD: Defines the key used to specify the base contract type of the plugin.
- CONTRACT_PREFIX and CONTRACT_SUFFIX: Define the keys used to denote the contracts
implemented by the plugin and their associated API levels.
- REQUIRED_PROVIDER_PREFIX and REQUIRED_PROVIDER_SUFFIX: Define the keys used to represent
required providers and their associated API levels.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic DescriptorReads a plugin plugin from the serialized properties format.static DescriptorReads a plugin plugin from the given string content.static StringtoContractLevel(Class<?> contractClass) static StringtoContractLevel(String contractFQCN) static StringtoFilename(Class<?> klass) static StringtoFilename(String fqcn) static Stringstatic Stringstatic StringtoRequiredProviderLevel(Class<?> providerClass) static StringtoRequiredProviderLevel(String providerFQCN) static StringtransformClassName(Class<?> klass) Transforms the provided class into its canonical name representation.static voidwrite(Descriptor descriptor, Writer writer) Serializes the providedDescriptorinto the givenWriterin the form of a properties file, encoding plugin metadata such as plugin class, plugin kind, implemented contracts, and required providers.
-
Field Details
-
DESCRIPTOR_DIRECTORY
- See Also:
-
DESCRIPTOR_EXTENSION
- See Also:
-
PLUGIN_CLASS_FIELD
- See Also:
-
PLUGIN_KIND_FIELD
- See Also:
-
CONTRACT_PREFIX
- See Also:
-
CONTRACT_SUFFIX
- See Also:
-
REQUIRED_PROVIDER_PREFIX
- See Also:
-
REQUIRED_PROVIDER_SUFFIX
- See Also:
-
-
Method Details
-
transformClassName
Transforms the provided class into its canonical name representation. Reusable in different places to keep serialization from class to FQCN aligned.- Parameters:
klass- theClassobject whose canonical name is to be returned- Returns:
- the name of the specified class, or null if the class does not have a name. Note: not using the canonical name to avoid issues with inner classes and de/serialization.
-
toFilename
-
toFilename
-
toPath
-
toPath
-
toContractLevel
-
toContractLevel
-
toRequiredProviderLevel
-
toRequiredProviderLevel
-
write
Serializes the providedDescriptorinto the givenWriterin the form of a properties file, encoding plugin metadata such as plugin class, plugin kind, implemented contracts, and required providers.- Parameters:
descriptor- theDescriptorcontaining the plugin metadata to be serializedwriter- theWriterwhere the plugin properties will be written- Throws:
IOException- if an I/O error occurs while writing to theWriter
-
read
Reads a plugin plugin from the serialized properties format.The returned plugin contains the mandatory plugin class and base contract fields, plus all parsed contract/provider API levels found in the input.
- Parameters:
reader- the character stream containing plugin properties- Returns:
- the parsed plugin.
- Throws:
IOException- if the properties cannot be readIllegalArgumentException- if mandatory fields are missing or if any level value cannot be parsed as an integer
-
read
Reads a plugin plugin from the given string content. This method parses the input string into aDescriptorobject. It internally utilizes aStringReaderto read the string and expects the content to be in a properties-based serialized format.- Parameters:
content- the string content containing serialized plugin properties- Returns:
- the parsed
Descriptor - Throws:
RuntimeException- if an I/O error occursIllegalArgumentException- if mandatory fields are missing
-