Interface FileConfig

    • Method Detail

      • getFile

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

        java.nio.file.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 java.lang.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​(java.io.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​(java.io.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​(java.nio.file.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​(java.nio.file.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​(java.lang.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​(java.lang.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​(java.io.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​(java.io.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​(java.nio.file.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​(java.nio.file.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​(java.lang.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​(java.lang.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​(java.io.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​(java.io.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​(java.nio.file.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​(java.nio.file.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​(java.lang.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​(java.lang.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