Class DefaultConfigReferenceLookup

java.lang.Object
tech.guilhermekaua.spigotboot.config.reference.DefaultConfigReferenceLookup
All Implemented Interfaces:
ConfigReferenceLookup

public class DefaultConfigReferenceLookup extends Object implements ConfigReferenceLookup
Default platform-neutral implementation of ConfigReferenceLookup.

Provides lookup capabilities for resolving config references by delegating to DefaultConfigManager for single configs and FolderConfigEntry for folder config items.

  • Constructor Details

    • DefaultConfigReferenceLookup

      public DefaultConfigReferenceLookup(@NotNull @NotNull DefaultConfigManager configManager)
      Creates a new lookup instance.
      Parameters:
      configManager - the config manager providing access to configs and folder configs
  • Method Details

    • findSingleConfigRoot

      @Nullable public @Nullable ConfigNode findSingleConfigRoot(@NotNull @NotNull String configName)
      Description copied from interface: ConfigReferenceLookup
      Finds the root node of a single config by name.
      Specified by:
      findSingleConfigRoot in interface ConfigReferenceLookup
      Parameters:
      configName - the config name (from @Config(name="..."))
      Returns:
      the root config node, or null if not found
    • findSingleConfigPath

      @Nullable public @Nullable ConfigNode findSingleConfigPath(@NotNull @NotNull String configName, @NotNull @NotNull String path)
      Description copied from interface: ConfigReferenceLookup
      Finds a node at a specific path within a single config.
      Specified by:
      findSingleConfigPath in interface ConfigReferenceLookup
      Parameters:
      configName - the config name
      path - the dot-separated path (e.g., "database.host")
      Returns:
      the node at the path, or null if config or path not found
    • findFolderConfigItemRoot

      @Nullable public @Nullable ConfigNode findFolderConfigItemRoot(@NotNull @NotNull String folderConfigName, @NotNull @NotNull String itemId)
      Description copied from interface: ConfigReferenceLookup
      Finds the root node of a folder config item.
      Specified by:
      findFolderConfigItemRoot in interface ConfigReferenceLookup
      Parameters:
      folderConfigName - the folder config name (from @FolderConfig(name="..."))
      itemId - the item ID (typically the filename without extension)
      Returns:
      the root node of the item, or null if not found
    • findFolderConfigItemPath

      @Nullable public @Nullable ConfigNode findFolderConfigItemPath(@NotNull @NotNull String folderConfigName, @NotNull @NotNull String itemId, @NotNull @NotNull String path)
      Description copied from interface: ConfigReferenceLookup
      Finds a node at a specific path within a folder config item.
      Specified by:
      findFolderConfigItemPath in interface ConfigReferenceLookup
      Parameters:
      folderConfigName - the folder config name
      itemId - the item ID
      path - the dot-separated path
      Returns:
      the node at the path, or null if folder config, item, or path not found
    • getAvailableConfigNames

      @NotNull public @NotNull Set<String> getAvailableConfigNames()
      Description copied from interface: ConfigReferenceLookup
      Gets all available single config names.

      Used for providing suggestions in error messages.

      Specified by:
      getAvailableConfigNames in interface ConfigReferenceLookup
      Returns:
      set of config names
    • getAvailableFolderConfigNames

      @NotNull public @NotNull Set<String> getAvailableFolderConfigNames()
      Description copied from interface: ConfigReferenceLookup
      Gets all available folder config names.

      Used for providing suggestions in error messages.

      Specified by:
      getAvailableFolderConfigNames in interface ConfigReferenceLookup
      Returns:
      set of folder config names
    • getAvailableItemIds

      @NotNull public @NotNull Set<String> getAvailableItemIds(@NotNull @NotNull String folderConfigName)
      Description copied from interface: ConfigReferenceLookup
      Gets all available item IDs within a folder config.

      Used for providing suggestions in error messages.

      Specified by:
      getAvailableItemIds in interface ConfigReferenceLookup
      Parameters:
      folderConfigName - the folder config name
      Returns:
      set of item IDs, or empty set if folder config not found
    • getAvailableKeysAt

      @NotNull public @NotNull Set<String> getAvailableKeysAt(@NotNull @NotNull String configName, @Nullable @Nullable String path)
      Description copied from interface: ConfigReferenceLookup
      Gets available keys at a path within a single config.

      If the node at the path is a map, returns its keys. Used for providing suggestions in error messages.

      Specified by:
      getAvailableKeysAt in interface ConfigReferenceLookup
      Parameters:
      configName - the config name
      path - the path (can be empty or null for root)
      Returns:
      set of available keys, or empty set if not a map or not found
    • hasConfig

      public boolean hasConfig(@NotNull @NotNull String configName)
      Description copied from interface: ConfigReferenceLookup
      Checks if a single config exists.
      Specified by:
      hasConfig in interface ConfigReferenceLookup
      Parameters:
      configName - the config name
      Returns:
      true if the config is registered
    • hasFolderConfig

      public boolean hasFolderConfig(@NotNull @NotNull String folderConfigName)
      Description copied from interface: ConfigReferenceLookup
      Checks if a folder config exists.
      Specified by:
      hasFolderConfig in interface ConfigReferenceLookup
      Parameters:
      folderConfigName - the folder config name
      Returns:
      true if the folder config is registered
    • hasFolderConfigItem

      public boolean hasFolderConfigItem(@NotNull @NotNull String folderConfigName, @NotNull @NotNull String itemId)
      Description copied from interface: ConfigReferenceLookup
      Checks if a folder config item exists.
      Specified by:
      hasFolderConfigItem in interface ConfigReferenceLookup
      Parameters:
      folderConfigName - the folder config name
      itemId - the item ID
      Returns:
      true if the item exists in the folder config