Class CustomFile
java.lang.Object
io.github.monsieurdoceo.filizer.storage.domain.CustomFile
Represents a managed configuration file.
A CustomFile provides a high-level API for creating,
reading, modifying, saving, and synchronizing YAML configuration files.
-
Constructor Summary
ConstructorsConstructorDescriptionCustomFile(File parent, String name, FileSynchronizer synchronizer, FilizerExceptions errors) Creates a newCustomFilefrom a parent directory and file name.CustomFile(Path path, String name, FileSynchronizer synchronizer, FilizerExceptions errors) Creates a newCustomFilefrom a parent path and file name. -
Method Summary
Modifier and TypeMethodDescriptiongetFile()Retrieves the underlying file instance.Retrieves the cachedFileReaderinstance.longReturns the last modified timestamp of the file.getName()Retrieves the file name.Sets multiple values in the file configuration.Sets a list of values in the file configuration.voidreload()Reloads the file configuration from disk.voidsave()Saves the current configuration to disk.section(ConfigurationSectionBuilder configSection) Creates and applies a configuration section.Sets a value in the file configuration.
-
Constructor Details
-
Method Details
-
save
public void save()Saves the current configuration to disk.- Throws:
IllegalStateException- if the file cannot be saved
-
reload
public void reload()Reloads the file configuration from disk.This method refreshes the underlying.
FileConfiguration, recreates the associatedFileReader, and updates the cached last-modified timestamp. -
getFileReader
Retrieves the cachedFileReaderinstance.If the underlying file has been modified externally, the configuration is automatically reloaded before returning the file reader.
- Returns:
- the file reader
-
set
Sets a value in the file configuration.- Parameters:
name- the configuration pathvalue- the value to store- Returns:
- the current
CustomFileinstance
-
list
Sets a list of values in the file configuration.- Parameters:
name- the configuration pathvalues- the values to store- Returns:
- the current
CustomFileinstance
-
list
Sets multiple values in the file configuration.This method behaves like
list(String, List)but accepts varargs values.- Parameters:
name- the configuration pathvalues- the values to store- Returns:
- the current
CustomFileinstance
-
section
Creates and applies a configuration section.- Parameters:
configSection- the section to apply- Returns:
- the current
CustomFileinstance
-
getName
Retrieves the file name.- Returns:
- the file name
-
getFile
Retrieves the underlying file instance.- Returns:
- the backing file
-
getLastModified
public long getLastModified()Returns the last modified timestamp of the file.- Returns:
- the last modified timestamp
-