Class DefaultFolderConfigEditor<T>
java.lang.Object
tech.guilhermekaua.spigotboot.config.folder.DefaultFolderConfigEditor<T>
- Type Parameters:
T- the item type
- All Implemented Interfaces:
FolderConfigEditor<T>
Default implementation of
FolderConfigEditor.
Delegates to FolderConfigEntry for actual persistence.
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultFolderConfigEditor(@NotNull FolderConfigEntry<T> entry) Creates a new editor. -
Method Summary
Modifier and TypeMethodDescription@NotNull EditResult<T>Creates a new item in the folder config.@NotNull EditResult<Void>Deletes an item from the folder config.@NotNull EditResult<T>Saves (overwrites) an item in the folder config.@NotNull EditResult<T>update(@NotNull String id, @NotNull UnaryOperator<T> mutator) Updates an existing item in the folder config.
-
Constructor Details
-
DefaultFolderConfigEditor
Creates a new editor.- Parameters:
entry- the folder config entry
-
-
Method Details
-
create
Description copied from interface:FolderConfigEditorCreates a new item in the folder config.- Specified by:
createin interfaceFolderConfigEditor<T>- Parameters:
id- the item ID (will be used as filename without extension)value- the item value- Returns:
- the edit result
-
save
Description copied from interface:FolderConfigEditorSaves (overwrites) an item in the folder config.If the item doesn't exist, it will be created.
- Specified by:
savein interfaceFolderConfigEditor<T>- Parameters:
id- the item IDvalue- 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:FolderConfigEditorUpdates 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:
updatein interfaceFolderConfigEditor<T>- Parameters:
id- the item IDmutator- the function to apply to the item copy- Returns:
- the edit result
-
delete
Description copied from interface:FolderConfigEditorDeletes an item from the folder config.- Specified by:
deletein interfaceFolderConfigEditor<T>- Parameters:
id- the item ID- Returns:
- the edit result (value is null for delete operations)
-