Package de.xima.fc.mdl
Class PluginID
- java.lang.Object
-
- de.xima.fc.mdl.PluginID
-
- All Implemented Interfaces:
Serializable
@Immutable public final class PluginID extends Object implements Serializable
Model for the ID of a plugin. Each plugin must have a Manifest with the entryPlugin-Key. Optionally, if the plugin consists of multiple files, it may also have aPlugin-File-Key. The ID of a plugin is the plugin key + the file key (empty string if not present).Note that there might still be legacy plugins without an ID, but these are deprecated and will not be supported in a later version anymore.
A plugin ID has a canonical string representation which is a URL path consisting of the key and the file key (if present), e.g.
key,key/fileKeyorsome%2fkey/fileKey.- Since:
- 8.0.0
- Author:
- XIMA MEDIA GmbH
- See Also:
- Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object obj)StringgetFileKey()Gets the plugin key of the plugin, from thePlugin-File-KeyManifest entry of the plugin.StringgetKey()Gets the plugin key of the plugin, from thePlugin-KeyManifest entry of the plugin.inthashCode()booleanisHasFileKey()Checks whether this ID has a file key.static Optional<PluginID>ofManifest(Manifest manifest)Extracts the plugin ID from the main attributes of a Manifest.static Optional<PluginID>ofManifestAttributes(Map<?,?> manifestAttributes)Extracts the plugin ID from the main attributes of a Manifest.static PluginIDparse(String id)Parses the canonical representation of a plugin ID, as returned bytoString().StringtoString()
-
-
-
Constructor Detail
-
PluginID
public PluginID(String key, String fileKey)
Creates a new plugin ID from the given components.- Parameters:
key- The key of the plugin, from thePlugin-KeyManifest entry of the plugin.fileKey- Optional file key of the plugin, from thePlugin-File-KeyManifest entry of the plugin.nullvalues are normalized to the empty string.- Throws:
IllegalArgumentException- When thekeyisnullor empty.
-
-
Method Detail
-
getFileKey
public String getFileKey()
Gets the plugin key of the plugin, from thePlugin-File-KeyManifest entry of the plugin. The file key is required only for plugins that consist of multiple files.- Returns:
- The file key of the plugin, never
nullbut might be empty.
-
getKey
public String getKey()
Gets the plugin key of the plugin, from thePlugin-KeyManifest entry of the plugin. The key is required for every plugin.- Returns:
- The key of the plugin
-
isHasFileKey
public boolean isHasFileKey()
Checks whether this ID has a file key.- Returns:
trueif thegetFileKey()is not empty, orfalseotherwise.
-
ofManifest
public static Optional<PluginID> ofManifest(Manifest manifest)
Extracts the plugin ID from the main attributes of a Manifest.- Parameters:
manifest- Manifest of a plugin JAR file.- Returns:
- The ID from the Manifest, or empty if the Manifest does not contain an ID or if the given Manifest was
null.
-
ofManifestAttributes
public static Optional<PluginID> ofManifestAttributes(Map<?,?> manifestAttributes)
Extracts the plugin ID from the main attributes of a Manifest.- Parameters:
manifestAttributes- Map with the Manifest attributes of a plugin JAR file. The values must be strings, the keys can be strings orManifest attribute names.- Returns:
- The ID from the Manifest, or empty if the Manifest attributes do not contain an ID.
-
parse
public static PluginID parse(String id)
Parses the canonical representation of a plugin ID, as returned bytoString().- Parameters:
id- ID to parse.- Returns:
- The parsed ID, or
nullif the given ID isnullor empty. - Throws:
IllegalArgumentException- When the ID string is invalid and neithernullnor empty.
-
-