Interface FileConfig

All Superinterfaces:
AutoCloseable, Config, UnmodifiableConfig
All Known Subinterfaces:
CommentedFileConfig
All Known Implementing Classes:
ConvertedCommentedFileConfig, ConvertedFileConfig

public interface FileConfig extends Config, AutoCloseable
  • Method Details

    • getFile

      File getFile()
      Returns:
      the config's file, as a classic File object
    • getNioPath

      Path getNioPath()
      Returns:
      the config's file, as a NIO Path object
    • save

      void save()
      Saves this config as soon as possible. This method may return quickly and perform the IO operations in background, or it may block until the operations are done.
    • load

      void load()
      (Re)loads this config from the file. This method blocks until the read operation completes.
    • close

      void close()
      Closes this FileConfig, releases its associated resources (if any), and ensure that the ongoing saving operations complete.

      A closed FileConfig can still be used via the Config's methods, but save() and load() will throw an IllegalStateException. Closing an aleady closed FileConfig has no effect.

      Specified by:
      close in interface AutoCloseable
    • checked

      default FileConfig checked()
      Description copied from interface: Config
      Returns a checked view of the config. It checks that all the values put into the config are supported by the config's format (as per the ConfigFormat.supportsType(Class) method. Trying to insert an unsupported value throws an IllegalArgumentException.

      The values that are in the config when this method is called are also checked.

      Specified by:
      checked in interface Config
      Returns:
      a checked view of the config.
    • of

      static FileConfig of(File file)
      Creates a new FileConfig based on the specified file. The format is detected automatically.
      Parameters:
      file - the file to use to save and load the config
      Returns:
      a new FileConfig associated to the specified file
      Throws:
      NoFormatFoundException - if the format detection fails
    • of

      static FileConfig of(File file, ConfigFormat<? extends Config> format)
      Creates a new FileConfig based on the specified file and format.
      Parameters:
      file - the file to use to save and load the config
      format - the config's format
      Returns:
      a new FileConfig associated to the specified file
    • of

      static FileConfig of(Path file)
      Creates a new FileConfig based on the specified file. The format is detected automatically.
      Parameters:
      file - the file to use to save and load the config
      Returns:
      a new FileConfig associated to the specified file
      Throws:
      NoFormatFoundException - if the format detection fails
    • of

      static FileConfig of(Path file, ConfigFormat<? extends Config> format)
      Creates a new FileConfig based on the specified file and format.
      Parameters:
      file - the file to use to save and load the config
      format - the config's format
      Returns:
      a new FileConfig associated to the specified file
    • of

      static FileConfig of(String filePath)
      Creates a new FileConfig based on the specified file. The format is detected automatically.
      Parameters:
      filePath - the file's path
      Returns:
      a new FileConfig associated to the specified file
      Throws:
      NoFormatFoundException - if the format detection fails
    • of

      static FileConfig of(String filePath, ConfigFormat<?> format)
      Creates a new FileConfig based on the specified file and format.
      Parameters:
      filePath - the file's path
      format - the config's format
      Returns:
      a new FileConfig associated to the specified file
    • ofConcurrent

      static FileConfig ofConcurrent(File file)
      Creates a new thread-safe FileConfig based on the specified file. The format is detected automatically.
      Parameters:
      file - the file to use to save and load the config
      Returns:
      a new thread-safe FileConfig associated to the specified file
      Throws:
      NoFormatFoundException - if the format detection fails
    • ofConcurrent

      static FileConfig ofConcurrent(File file, ConfigFormat<?> format)
      Creates a new thread-safe FileConfig based on the specified file and format.
      Parameters:
      file - the file to use to save and load the config
      format - the config's format
      Returns:
      a new thread-safe FileConfig associated to the specified file
    • ofConcurrent

      static FileConfig ofConcurrent(Path file)
      Creates a new thread-safe FileConfig based on the specified file. The format is detected automatically.
      Parameters:
      file - the file to use to save and load the config
      Returns:
      a new thread-safe FileConfig associated to the specified file
      Throws:
      NoFormatFoundException - if the format detection fails
    • ofConcurrent

      static FileConfig ofConcurrent(Path file, ConfigFormat<?> format)
      Creates a new thread-safe FileConfig based on the specified file and format.
      Parameters:
      file - the file to use to save and load the config
      format - the config's format
      Returns:
      a new thread-safe FileConfig associated to the specified file
    • ofConcurrent

      static FileConfig ofConcurrent(String filePath)
      Creates a new thread-safe FileConfig based on the specified file. The format is detected automatically.
      Parameters:
      filePath - the file's path
      Returns:
      a new thread-safe FileConfig associated to the specified file
      Throws:
      NoFormatFoundException - if the format detection fails
    • ofConcurrent

      static FileConfig ofConcurrent(String filePath, ConfigFormat<?> format)
      Creates a new thread-safe FileConfig based on the specified file and format.
      Parameters:
      filePath - the file's path
      format - the config's format
      Returns:
      a new thread-safe FileConfig associated to the specified file
    • builder

      static FileConfigBuilder builder(File file)
      Returns a FileConfigBuilder to create a FileConfig with many options. The format is detected automatically.
      Parameters:
      file - the file to use to save and load the config
      Returns:
      a new FileConfigBuilder that will build a FileConfig associated to the specified file
      Throws:
      NoFormatFoundException - if the format detection fails
    • builder

      static FileConfigBuilder builder(File file, ConfigFormat<?> format)
      Returns a FileConfigBuilder to create a FileConfig with many options.
      Parameters:
      file - the file to use to save and load the config
      format - the config's format
      Returns:
      a new FileConfigBuilder that will build a FileConfig associated to the specified file
    • builder

      static FileConfigBuilder builder(Path file)
      Returns a FileConfigBuilder to create a FileConfig with many options. The format is detected automatically.
      Parameters:
      file - the file to use to save and load the config
      Returns:
      a new FileConfigBuilder that will build a FileConfig associated to the specified file
      Throws:
      NoFormatFoundException - if the format detection fails
    • builder

      static FileConfigBuilder builder(Path file, ConfigFormat<?> format)
      Returns a FileConfigBuilder to create a FileConfig with many options.
      Parameters:
      file - the file to use to save and load the config
      format - the config's format
      Returns:
      a new FileConfigBuilder that will build a FileConfig associated to the specified file
    • builder

      static FileConfigBuilder builder(String filePath)
      Returns a FileConfigBuilder to create a FileConfig with many options. The format is detected automatically.
      Parameters:
      filePath - the file's path
      Returns:
      a new FileConfigBuilder that will build a FileConfig associated to the specified file
      Throws:
      NoFormatFoundException - if the format detection fails
    • builder

      static FileConfigBuilder builder(String filePath, ConfigFormat<?> format)
      Returns a FileConfigBuilder to create a FileConfig with many options.
      Parameters:
      filePath - the file's path
      format - the config's format
      Returns:
      a new FileConfigBuilder that will build a FileConfig associated to the specified file