java.lang.Object
com.winterhavenmc.library.messagebuilder.adapters.pipeline.resolvers.value.CompositeResolver
All Implemented Interfaces:
ValueResolver

public class CompositeResolver extends Object implements ValueResolver
A ValueResolver implementation that handles complex or structured objects by applying one or more matching Accessor instances.

The CompositeResolver delegates the resolution process to registered adapters that know how to transform an object into a set of string values, each of which is mapped to a derived ValidMacroKey. The resolved entries typically include sub-keys that extend the base string in a dot-notated form.

This resolver does not overwrite existing entries in the base string when used in conjunction with a MacroValueResolver; it merely returns all extracted string-value pairs. The calling resolver is responsible for deciding merge behavior.

Example flow:

  1. Retrieve the object from the MacroObjectMap using the given macroKey.
  2. Find all matching adapters for the object via the FieldAccessorRegistry.
  3. For each adapter, adapt the object and extract string-value mappings via the MacroFieldAccessor.
  4. Aggregate all mappings into a MacroStringMap.
See Also:
  • Constructor Details

    • CompositeResolver

      public CompositeResolver(AccessorRegistry accessorRegistry, MacroFieldAccessor macroFieldAccessor)
      Constructs a CompositeResolver with the given adapter registry and field extractor.
      Parameters:
      accessorRegistry - an instance that manages and matches Accessor objects
      macroFieldAccessor - an instance used to extract field values from adapted objects
  • Method Details

    • resolve

      public MacroStringMap resolve(ValidMacroKey macroKey, MacroObjectMap macroObjectMap)
      Resolves a ValidMacroKey by attempting to adapt the associated object from the MacroObjectMap using applicable Accessor instances.

      For each adapter that supports the object, this method invokes the adapter’s adapt method, then extracts sub-string mappings via the MacroFieldAccessor.

      The resulting MacroStringMap contains mappings for the derived sub-keys. The base string may also be included if provided by the adapter and extractor.

      Specified by:
      resolve in interface ValueResolver
      Parameters:
      macroKey - the string used to retrieve the source object from the macro object map
      macroObjectMap - the object map containing input values to be resolved
      Returns:
      a MacroStringMap containing resolved sub-string mappings for the adapted object