Class PlaceholderStore

java.lang.Object
tech.guilhermekaua.spigotboot.placeholder.registry.PlaceholderStore

public class PlaceholderStore extends Object
Holds the registered placeholder metadata and resolves it by parameter string.

This store owns the placeholder lookup table so that the component producing placeholders (PlaceholderRegistry) and the component consuming them (PAPIExpansion) can both depend on a shared, neutral collaborator instead of on each other. Decoupling the lookup from both sides breaks the registry/expansion dependency cycle while keeping a single source of truth for placeholder data.

  • Constructor Details

    • PlaceholderStore

      public PlaceholderStore()
  • Method Details

    • register

      public void register(@NotNull @NotNull PlaceholderMetadata metadata)
      Registers placeholder metadata, keyed by its placeholder pattern.

      Re-registering the same pattern overwrites the previous metadata.

      Parameters:
      metadata - the placeholder metadata to store, not null
    • findPlaceholderMetadata

      @Nullable public @Nullable PlaceholderMetadata findPlaceholderMetadata(@NotNull @NotNull String params)
      Finds the placeholder metadata matching the given parameter string.

      An exact key match takes precedence: if a placeholder is registered under exactly params it is returned directly. Otherwise the first placeholder whose parameter syntax accepts the supplied value is returned (see PlaceholderParameterParser.isValidPlaceholderPattern(String, String)). Resolving exact matches first keeps lookup deterministic regardless of map iteration order.

      Parameters:
      params - the placeholder parameter string requested, not null
      Returns:
      the matching metadata, or null if none matches
    • clear

      public void clear()
      Removes all registered placeholders.