java.lang.Object
com.winterhavenmc.library.messagebuilder.pipeline.adapters.AdapterRegistry

public class AdapterRegistry extends Object
Maintains an ordered registry of all Adapter instances available to the macro resolution pipeline.

This registry is responsible for:

  • Registering built-in adapters at construction time, in a defined priority order
  • Allowing additional plugin-defined adapters to be registered at runtime
  • Providing a filtered stream of adapters that support a given object type

Adapters are evaluated in the order they are registered, ensuring predictable precedence when multiple adapters populate the same macro keys. The first adapter to return a value for a given key wins, and later adapters cannot overwrite it.

This allows plugin developers and library consumers to control the resolution order by selectively registering their own adapters before or after the built-in set.

See Also:
  • Constructor Details

    • AdapterRegistry

      public AdapterRegistry(AdapterContextContainer ctx)
      Constructs an AdapterRegistry and registers all built-in adapters in preferred priority order.
      Parameters:
      ctx - a context container providing shared utilities to each adapter
  • Method Details

    • register

      public final void register(Adapter adapter)
      Registers a new Adapter into the registry.

      Adapters are added to the end of the internal list and evaluated in the order they were registered. It is the caller's responsibility to ensure adapters are registered in a preferred resolution priority.

      Parameters:
      adapter - the adapter to register
      Throws:
      NullPointerException - if the adapter is null
    • getMatchingAdapters

      public Stream<Adapter> getMatchingAdapters(Object object)
      Returns a stream of all registered Adapter instances that support the given object.

      Each adapter is evaluated in order, and only those for which Adapter.supports(Object) returns true are included in the result.

      Parameters:
      object - the object to test for adapter support
      Returns:
      a stream of supporting adapters, or an empty stream if the object is null