Class DefaultFolderConfigEditor<T>

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

public final class DefaultFolderConfigEditor<T> extends Object implements FolderConfigEditor<T>
Default implementation of FolderConfigEditor.

Delegates to FolderConfigEntry for actual persistence.

  • Constructor Details

    • DefaultFolderConfigEditor

      public DefaultFolderConfigEditor(@NotNull @NotNull FolderConfigEntry<T> entry)
      Creates a new editor.
      Parameters:
      entry - the folder config entry
  • Method Details

    • create

      @NotNull public @NotNull EditResult<T> create(@NotNull @NotNull String id, @NotNull T value)
      Description copied from interface: FolderConfigEditor
      Creates a new item in the folder config.
      Specified by:
      create in interface FolderConfigEditor<T>
      Parameters:
      id - the item ID (will be used as filename without extension)
      value - the item value
      Returns:
      the edit result
    • save

      @NotNull public @NotNull EditResult<T> save(@NotNull @NotNull String id, @NotNull T value)
      Description copied from interface: FolderConfigEditor
      Saves (overwrites) an item in the folder config.

      If the item doesn't exist, it will be created.

      Specified by:
      save in interface FolderConfigEditor<T>
      Parameters:
      id - the item ID
      value - the new item value
      Returns:
      the edit result
    • update

      @NotNull public @NotNull EditResult<T> update(@NotNull @NotNull String id, @NotNull @NotNull UnaryOperator<T> mutator)
      Description copied from interface: FolderConfigEditor
      Updates an existing item in the folder config.

      The mutator receives a copy of the current item and should return the modified version. The original item is not modified.

      Specified by:
      update in interface FolderConfigEditor<T>
      Parameters:
      id - the item ID
      mutator - the function to apply to the item copy
      Returns:
      the edit result
    • delete

      @NotNull public @NotNull EditResult<Void> delete(@NotNull @NotNull String id)
      Description copied from interface: FolderConfigEditor
      Deletes an item from the folder config.
      Specified by:
      delete in interface FolderConfigEditor<T>
      Parameters:
      id - the item ID
      Returns:
      the edit result (value is null for delete operations)