Class DefaultFolderConfigSnapshot<T>

java.lang.Object
tech.guilhermekaua.spigotboot.config.folder.DefaultFolderConfigSnapshot<T>
Type Parameters:
T - the item type
All Implemented Interfaces:
FolderConfigSnapshot<T>

public final class DefaultFolderConfigSnapshot<T> extends Object implements FolderConfigSnapshot<T>
Default implementation of FolderConfigSnapshot.

This is an immutable snapshot that is swapped atomically on reload.

  • Constructor Details

    • DefaultFolderConfigSnapshot

      public DefaultFolderConfigSnapshot(@NotNull @NotNull Class<T> itemType, @NotNull @NotNull String folderConfigName, @NotNull @NotNull Map<String,T> itemsById, @NotNull @NotNull List<T> orderedValues, @Nullable @Nullable List<T> enabledValues)
      Creates a new snapshot.
      Parameters:
      itemType - the item type class
      folderConfigName - the folder config name
      itemsById - map of items by ID
      orderedValues - ordered list of all values
      enabledValues - list of enabled values
  • Method Details

    • empty

      public static <T> DefaultFolderConfigSnapshot<T> empty(@NotNull @NotNull Class<T> itemType, @NotNull @NotNull String folderConfigName)
      Creates an empty snapshot.
      Type Parameters:
      T - the item type
      Parameters:
      itemType - the item type class
      folderConfigName - the folder config name
      Returns:
      an empty snapshot
    • get

      @NotNull public T get(@NotNull @NotNull String id)
      Description copied from interface: FolderConfigSnapshot
      Gets an item by its ID.
      Specified by:
      get in interface FolderConfigSnapshot<T>
      Parameters:
      id - the item ID (filename without extension)
      Returns:
      the item
    • find

      @Nullable public T find(@NotNull @NotNull String id)
      Description copied from interface: FolderConfigSnapshot
      Finds an item by its ID.
      Specified by:
      find in interface FolderConfigSnapshot<T>
      Parameters:
      id - the item ID (filename without extension)
      Returns:
      the item, or null if not found
    • values

      @NotNull public @NotNull Collection<T> values()
      Description copied from interface: FolderConfigSnapshot
      Returns all items in the folder config in their configured order.
      Specified by:
      values in interface FolderConfigSnapshot<T>
      Returns:
      an unmodifiable collection of all items
    • ids

      @NotNull public @NotNull Set<String> ids()
      Description copied from interface: FolderConfigSnapshot
      Returns all item IDs in the folder config.
      Specified by:
      ids in interface FolderConfigSnapshot<T>
      Returns:
      an unmodifiable set of all IDs
    • enabled

      @NotNull public @NotNull Collection<T> enabled()
      Description copied from interface: FolderConfigSnapshot
      Returns only enabled items if enabled filtering is configured.

      If enabled filtering is not configured (enabledField is empty or the field doesn't exist), this returns the same as FolderConfigSnapshot.values().

      Specified by:
      enabled in interface FolderConfigSnapshot<T>
      Returns:
      an unmodifiable collection of enabled items
    • contains

      public boolean contains(@NotNull @NotNull String id)
      Description copied from interface: FolderConfigSnapshot
      Checks if an item with the given ID exists.
      Specified by:
      contains in interface FolderConfigSnapshot<T>
      Parameters:
      id - the item ID to check
      Returns:
      true if an item with this ID exists
    • size

      public int size()
      Description copied from interface: FolderConfigSnapshot
      Returns the number of items in this snapshot.
      Specified by:
      size in interface FolderConfigSnapshot<T>
      Returns:
      the item count
    • isEmpty

      public boolean isEmpty()
      Description copied from interface: FolderConfigSnapshot
      Returns true if this snapshot contains no items.
      Specified by:
      isEmpty in interface FolderConfigSnapshot<T>
      Returns:
      true if empty
    • getItemType

      @NotNull public @NotNull Class<T> getItemType()
      Description copied from interface: FolderConfigSnapshot
      Gets the item type class.
      Specified by:
      getItemType in interface FolderConfigSnapshot<T>
      Returns:
      the item class
    • getFolderConfigName

      @NotNull public @NotNull String getFolderConfigName()
      Description copied from interface: FolderConfigSnapshot
      Gets the folder config name.
      Specified by:
      getFolderConfigName in interface FolderConfigSnapshot<T>
      Returns:
      the folder config name
    • getItemsMap

      @NotNull public @NotNull Map<String,T> getItemsMap()
      Gets the internal items map for building diffs.
      Returns:
      the items map