Record Class PluginDescriptor<T extends Plugin>

java.lang.Object
java.lang.Record
io.gdcc.spi.meta.descriptor.PluginDescriptor<T>
Type Parameters:
T - the base plugin contract type under which this plugin was resolved
Record Components:
sourceLocation - the source location from which the plugin was loaded, such as a JAR file or exploded classpath directory
identity - the logical plugin identity reported by the plugin instance; intended for distinguishing plugins at runtime
pluginClass - the concrete implementation class of the plugin
kindClass - the resolved base plugin contract implemented by the plugin
contracts - all resolved plugin contracts implemented by the plugin, mapped to their declared API levels
requiredProviders - all resolved core providers required by the plugin, mapped to their required API levels

public record PluginDescriptor<T extends Plugin>(Path sourceLocation, String identity, Class<? extends T extends Plugin> pluginClass, Class<T extends Plugin> kindClass, Map<Class<? extends Plugin>,Integer> contracts, Map<Class<? extends CoreProvider>,Integer> requiredProviders) extends Record
Runtime-facing descriptor of a resolved and loaded plugin implementation.

This descriptor represents a plugin after metadata has been interpreted in the context of the running application and the relevant Java types have been resolved. Unlike the build-time or serialized descriptor form, this model uses actual Class references for the plugin implementation, its base contract, all implemented plugin contracts, and all required core providers.

The generic type parameter T represents the base plugin contract under which the plugin was resolved and loaded. The pluginClass is therefore guaranteed to implement that base contract, while kindClass denotes the concrete base plugin contract itself.

The contracts map contains all plugin contracts implemented by the plugin together with their declared API levels. This includes the base contract as well as any optional capability contracts. The requiredProviders map contains all core providers required by the plugin's implemented contracts, again paired with their declared API levels.

  • Constructor Details

  • Method Details

    • implementsContract

      public boolean implementsContract(Class<? extends Plugin> contractClass)
    • contractLevel

      public OptionalInt contractLevel(Class<? extends Plugin> contractClass)
    • requiresProvider

      public boolean requiresProvider(Class<? extends CoreProvider> providerClass)
    • requiredProviderLevel

      public OptionalInt requiredProviderLevel(Class<? extends CoreProvider> providerClass)
    • normalizedIdentity

      public String normalizedIdentity()
      Returns the normalized identity string of this plugin. The normalization process converts the identity to lowercase and removes special characters such as "/\\-_:.#~*", ensuring a consistent format for comparison purposes.
      Returns:
      the normalized identity string, or null if the original identity is null
    • equals

      public boolean equals(Object obj)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      obj - the object with which to compare
      Returns:
      true if this object is the same as the obj argument; false otherwise.
    • hashCode

      public int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • sourceLocation

      public Path sourceLocation()
      Returns the value of the sourceLocation record component.
      Returns:
      the value of the sourceLocation record component
    • identity

      public String identity()
      Returns the value of the identity record component.
      Returns:
      the value of the identity record component
    • pluginClass

      public Class<? extends T> pluginClass()
      Returns the value of the pluginClass record component.
      Returns:
      the value of the pluginClass record component
    • kindClass

      public Class<T> kindClass()
      Returns the value of the kindClass record component.
      Returns:
      the value of the kindClass record component
    • contracts

      public Map<Class<? extends Plugin>,Integer> contracts()
      Returns the value of the contracts record component.
      Returns:
      the value of the contracts record component
    • requiredProviders

      public Map<Class<? extends CoreProvider>,Integer> requiredProviders()
      Returns the value of the requiredProviders record component.
      Returns:
      the value of the requiredProviders record component