java.lang.Object
com.winterhavenmc.library.messagebuilder.pipeline.resolvers.CompositeResolver
All Implemented Interfaces:
Resolver

public class CompositeResolver extends Object implements Resolver
A Resolver implementation that handles complex or structured objects by applying one or more matching Adapter 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 MacroKey. The resolved entries typically include sub-keys that extend the base key in a dot-notated form.

This resolver does not overwrite existing entries in the base key when used in conjunction with a FieldResolver; it merely returns all extracted key-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 AdapterRegistry.
  3. For each adapter, adapt the object and extract key-value mappings via the FieldExtractor.
  4. Aggregate all mappings into a MacroStringMap.
See Also:
  • Constructor Details

    • CompositeResolver

      public CompositeResolver(AdapterRegistry adapterRegistry, FieldExtractor fieldExtractor)
      Constructs a CompositeResolver with the given adapter registry and field extractor.
      Parameters:
      adapterRegistry - an instance that manages and matches Adapter objects
      fieldExtractor - an instance used to extract field values from adapted objects
  • Method Details

    • resolve

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

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

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

      Specified by:
      resolve in interface Resolver
      Parameters:
      macroKey - the key 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-key mappings for the adapted object