Class ConfigReferenceParser

java.lang.Object
tech.guilhermekaua.spigotboot.config.reference.ConfigReferenceParser

public class ConfigReferenceParser extends Object
Parses config reference tokens from string values.

Reference syntax:

  • ${configName} - single config root
  • ${configName:path.to.value} - single config with path
  • ${folderConfigName.itemId} - folder config item root
  • ${folderConfigName.itemId:path.to.value} - folder config item with path

Names (configName, folderConfigName, itemId) must match [a-zA-Z0-9_-]+. Names cannot contain '.' or ':' as these are used as delimiters.

  • Constructor Details

    • ConfigReferenceParser

      public ConfigReferenceParser()
  • Method Details

    • tryParse

      @NotNull public @NotNull Optional<ConfigReference> tryParse(@NotNull @NotNull String value)
      Attempts to parse a string value as a config reference.

      Only parses if the entire value is exactly a reference token (no interpolation).

      Parameters:
      value - the string value to parse
      Returns:
      the parsed reference, or empty if not a valid reference
    • looksLikeReference

      public boolean looksLikeReference(@NotNull @NotNull String value)
      Checks if a string value looks like a reference token.

      This is a quick check that doesn't validate the full syntax.

      Parameters:
      value - the value to check
      Returns:
      true if it looks like a reference
    • isValidName

      public boolean isValidName(@NotNull @NotNull String name)
      Validates that a name is valid for use in references.

      Valid names contain only letters, digits, underscores, and hyphens. Names cannot contain '.' or ':' as these are delimiter characters.

      Parameters:
      name - the name to validate
      Returns:
      true if valid