Class DefaultFolderConfigSnapshot<T>
java.lang.Object
tech.guilhermekaua.spigotboot.config.folder.DefaultFolderConfigSnapshot<T>
- Type Parameters:
T- the item type
- All Implemented Interfaces:
FolderConfigSnapshot<T>
Default implementation of
FolderConfigSnapshot.
This is an immutable snapshot that is swapped atomically on reload.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanChecks if an item with the given ID exists.static <T> DefaultFolderConfigSnapshot<T>Creates an empty snapshot.@NotNull Collection<T>enabled()Returns only enabled items if enabled filtering is configured.Finds an item by its ID.Gets an item by its ID.@NotNull StringGets the folder config name.Gets the internal items map for building diffs.Gets the item type class.ids()Returns all item IDs in the folder config.booleanisEmpty()Returns true if this snapshot contains no items.intsize()Returns the number of items in this snapshot.@NotNull Collection<T>values()Returns all items in the folder config in their configured order.
-
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 classfolderConfigName- the folder config nameitemsById- map of items by IDorderedValues- ordered list of all valuesenabledValues- 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 classfolderConfigName- the folder config name- Returns:
- an empty snapshot
-
get
Description copied from interface:FolderConfigSnapshotGets an item by its ID.- Specified by:
getin interfaceFolderConfigSnapshot<T>- Parameters:
id- the item ID (filename without extension)- Returns:
- the item
-
find
Description copied from interface:FolderConfigSnapshotFinds an item by its ID.- Specified by:
findin interfaceFolderConfigSnapshot<T>- Parameters:
id- the item ID (filename without extension)- Returns:
- the item, or null if not found
-
values
Description copied from interface:FolderConfigSnapshotReturns all items in the folder config in their configured order.- Specified by:
valuesin interfaceFolderConfigSnapshot<T>- Returns:
- an unmodifiable collection of all items
-
ids
Description copied from interface:FolderConfigSnapshotReturns all item IDs in the folder config.- Specified by:
idsin interfaceFolderConfigSnapshot<T>- Returns:
- an unmodifiable set of all IDs
-
enabled
Description copied from interface:FolderConfigSnapshotReturns 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:
enabledin interfaceFolderConfigSnapshot<T>- Returns:
- an unmodifiable collection of enabled items
-
contains
Description copied from interface:FolderConfigSnapshotChecks if an item with the given ID exists.- Specified by:
containsin interfaceFolderConfigSnapshot<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:FolderConfigSnapshotReturns the number of items in this snapshot.- Specified by:
sizein interfaceFolderConfigSnapshot<T>- Returns:
- the item count
-
isEmpty
public boolean isEmpty()Description copied from interface:FolderConfigSnapshotReturns true if this snapshot contains no items.- Specified by:
isEmptyin interfaceFolderConfigSnapshot<T>- Returns:
- true if empty
-
getItemType
Description copied from interface:FolderConfigSnapshotGets the item type class.- Specified by:
getItemTypein interfaceFolderConfigSnapshot<T>- Returns:
- the item class
-
getFolderConfigName
Description copied from interface:FolderConfigSnapshotGets the folder config name.- Specified by:
getFolderConfigNamein interfaceFolderConfigSnapshot<T>- Returns:
- the folder config name
-
getItemsMap
Gets the internal items map for building diffs.- Returns:
- the items map
-