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/fileKey
orsome%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 boolean
equals(Object obj)
String
getFileKey()
Gets the plugin key of the plugin, from thePlugin-File-Key
Manifest entry of the plugin.String
getKey()
Gets the plugin key of the plugin, from thePlugin-Key
Manifest entry of the plugin.int
hashCode()
boolean
isHasFileKey()
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 PluginID
parse(String id)
Parses the canonical representation of a plugin ID, as returned bytoString()
.String
toString()
-
-
-
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-Key
Manifest entry of the plugin.fileKey
- Optional file key of the plugin, from thePlugin-File-Key
Manifest entry of the plugin.null
values are normalized to the empty string.- Throws:
IllegalArgumentException
- When thekey
isnull
or empty.
-
-
Method Detail
-
getFileKey
public String getFileKey()
Gets the plugin key of the plugin, from thePlugin-File-Key
Manifest 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
null
but might be empty.
-
getKey
public String getKey()
Gets the plugin key of the plugin, from thePlugin-Key
Manifest 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:
true
if thegetFileKey()
is not empty, orfalse
otherwise.
-
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
null
if the given ID isnull
or empty. - Throws:
IllegalArgumentException
- When the ID string is invalid and neithernull
nor empty.
-
-