java.lang.Object
com.winterhavenmc.library.messagebuilder.pipeline.matcher.PlaceholderMatcher
All Implemented Interfaces:
Matcher

public class PlaceholderMatcher extends Object implements Matcher
Default implementation of the Matcher 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 MacroKey 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

    • PlaceholderMatcher

      public PlaceholderMatcher()
  • Method Details

    • match

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

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

      Specified by:
      match in interface Matcher
      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 MacroKey instances (may be empty but never null)