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 entry Plugin-Key. Optionally, if the plugin consists of multiple files, it may also have a Plugin-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 or some%2fkey/fileKey.

Since:
8.0.0
Author:
XIMA MEDIA GmbH
See Also:
  • Constructor Details

    • PluginID

      public PluginID(String key, String fileKey)
      Creates a new plugin ID from the given components.
      Parameters:
      key - The key of the plugin, from the Plugin-Key Manifest entry of the plugin.
      fileKey - Optional file key of the plugin, from the Plugin-File-Key Manifest entry of the plugin. null values are normalized to the empty string.
      Throws:
      IllegalArgumentException - When the key is null or empty.
  • Method Details

    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • getFileKey

      public String getFileKey()
      Gets the plugin key of the plugin, from the Plugin-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 the Plugin-Key Manifest entry of the plugin. The key is required for every plugin.
      Returns:
      The key of the plugin
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • isHasFileKey

      public boolean isHasFileKey()
      Checks whether this ID has a file key.
      Returns:
      true if the getFileKey() is not empty, or false otherwise.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • 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 or Manifest 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 by toString().
      Parameters:
      id - ID to parse.
      Returns:
      The parsed ID, or null if the given ID is null or empty.
      Throws:
      IllegalArgumentException - When the ID string is invalid and neither null nor empty.