java.lang.Object
com.winterhavenmc.library.messagebuilder.adapters.pipeline.matchers.RegexPlaceholderMatcher
All Implemented Interfaces:
PlaceholderMatcher

public class RegexPlaceholderMatcher extends Object implements PlaceholderMatcher
Default implementation of the PlaceholderMatcher interface that uses Java’s built-in Pattern and MatchResult APIs to extract macro keys from an input string.

This class transforms matching groups into ValidMacroKey instances using MacroKey.of(...), and silently skips any invalid results.

It is designed for use in both the resolution and replacement stages of the pipeline, depending on whether base keys or full macro keys are being matched.

See Also:
  • Constructor Details

    • RegexPlaceholderMatcher

      public RegexPlaceholderMatcher()
  • Method Details

    • match

      public Stream<ValidMacroKey> match(String input, Pattern pattern)
      Description copied from interface: PlaceholderMatcher
      Extracts macro keys from the given input string using the specified regular expression pattern.

      Each successful match is converted into a ValidMacroKey. Implementations may choose to skip invalid or malformed macro segments.

      Specified by:
      match in interface PlaceholderMatcher
      Parameters:
      input - the raw string to search for macros (e.g., a message from the YAML file)
      pattern - the regular expression pattern used to locate macro placeholders
      Returns:
      a stream of matched LegacyMacroKey instances (may be empty but never null)