Interface FolderConfigRef<T>

Type Parameters:
T - the item type
All Superinterfaces:
Supplier<FolderConfigSnapshot<T>>
All Known Implementing Classes:
DefaultFolderConfigRef

public interface FolderConfigRef<T> extends Supplier<FolderConfigSnapshot<T>>
A live reference to a folder-based configuration that updates on reload.

This is the primary injection type for folder configs. It provides access to the current snapshot, edit operations, and reload capabilities.

The underlying snapshot is swapped atomically on reload, so all reads from a single get() call see a consistent state.

  • Method Details

    • get

      @NotNull @NotNull FolderConfigSnapshot<T> get()
      Gets the current snapshot of the folder config.
      Specified by:
      get in interface Supplier<T>
      Returns:
      the current snapshot, never null
    • edit

      @NotNull @NotNull FolderConfigEditor<T> edit()
      Gets an editor for modifying the folder config.

      The editor provides create/update/delete operations that persist to disk and update the in-memory snapshot atomically.

      Returns:
      the folder config editor
    • reloadAll

      void reloadAll()
      Reloads the entire folder config from disk.

      This scans the folder, loads all matching files, and swaps the snapshot atomically. Listeners are notified of any changes.

    • reloadItem

      void reloadItem(@NotNull @NotNull String id)
      Reloads a single item from disk.

      If the file no longer exists, the item is removed from the folder config. If this is a new file, the item is added. Listeners are notified.

      Parameters:
      id - the item ID to reload
    • addListener

      void addListener(@NotNull @NotNull FolderConfigChangeListener<T> listener)
      Adds a listener for folder config changes.
      Parameters:
      listener - the listener to add
    • removeListener

      void removeListener(@NotNull @NotNull FolderConfigChangeListener<T> listener)
      Removes a previously added listener.
      Parameters:
      listener - the listener to remove
    • getItemType

      @NotNull @NotNull Class<T> getItemType()
      Gets the item type class.
      Returns:
      the item class
    • getFolderConfigName

      @NotNull @NotNull String getFolderConfigName()
      Gets the folder config name.
      Returns:
      the folder config name