java.lang.Object
com.winterhavenmc.library.messagebuilder.adapters.pipeline.accessors.FieldAccessorRegistry
All Implemented Interfaces:
AccessorRegistry

public class FieldAccessorRegistry extends Object implements AccessorRegistry
Maintains an ordered registry of all Accessor instances available to the macro resolution pipeline.

This registry is responsible for:

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

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

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

See Also:
  • Constructor Details

    • FieldAccessorRegistry

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

    • register

      public final void register(Accessor accessor)
      Registers a new Accessor 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 accessors are registered in a preferred resolution priority.

      Specified by:
      register in interface AccessorRegistry
      Parameters:
      accessor - the accessor to register
      Throws:
      NullPointerException - if the accessor is null
    • getMatchingAdapters

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

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

      Specified by:
      getMatchingAdapters in interface AccessorRegistry
      Parameters:
      object - the object to test for adapter support
      Returns:
      a stream of supporting accessors, or an empty stream if the object is null