java.lang.Object
io.github.monsieurdoceo.filizer.storage.domain.CustomFile

public class CustomFile extends Object
Represents a managed configuration file.

A CustomFile provides a high-level API for creating, reading, modifying, saving, and synchronizing YAML configuration files.

  • Constructor Details

    • CustomFile

      public CustomFile(Path path, String name, FileSynchronizer synchronizer, FilizerExceptions errors)
      Creates a new CustomFile from a parent path and file name.
      Parameters:
      path - the parent directory path
      name - the file name
      synchronizer - the synchronization service to use
      errors - the exception factory
    • CustomFile

      public CustomFile(File parent, String name, FileSynchronizer synchronizer, FilizerExceptions errors)
      Creates a new CustomFile from a parent directory and file name.
      Parameters:
      parent - the parent directory
      name - the file name
      synchronizer - the synchronization service to use
      errors - the exception factory
  • 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 associated

      FileReader, and updates the cached last-modified timestamp.

    • getFileReader

      public FileReader getFileReader()
      Retrieves the cached FileReader instance.

      If the underlying file has been modified externally, the configuration is automatically reloaded before returning the file reader.

      Returns:
      the file reader
    • set

      public CustomFile set(String name, Object value)
      Sets a value in the file configuration.
      Parameters:
      name - the configuration path
      value - the value to store
      Returns:
      the current CustomFile instance
    • list

      public CustomFile list(String name, List<?> values)
      Sets a list of values in the file configuration.
      Parameters:
      name - the configuration path
      values - the values to store
      Returns:
      the current CustomFile instance
    • list

      public CustomFile list(String name, Object... values)
      Sets multiple values in the file configuration.

      This method behaves like list(String, List) but accepts varargs values.

      Parameters:
      name - the configuration path
      values - the values to store
      Returns:
      the current CustomFile instance
    • section

      public CustomFile section(ConfigurationSectionBuilder configSection)
      Creates and applies a configuration section.
      Parameters:
      configSection - the section to apply
      Returns:
      the current CustomFile instance
    • getName

      public String getName()
      Retrieves the file name.
      Returns:
      the file name
    • getFile

      public File 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