Interface FileConfig
-
- All Superinterfaces:
java.lang.AutoCloseable,Config,UnmodifiableConfig
- All Known Subinterfaces:
CommentedFileConfig
- All Known Implementing Classes:
ConvertedCommentedFileConfig,ConvertedFileConfig
public interface FileConfig extends Config, java.lang.AutoCloseable
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.electronwill.nightconfig.core.Config
Config.Entry
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description static FileConfigBuilderbuilder(java.io.File file)Returns a FileConfigBuilder to create a FileConfig with many options.static FileConfigBuilderbuilder(java.io.File file, ConfigFormat<?> format)Returns a FileConfigBuilder to create a FileConfig with many options.static FileConfigBuilderbuilder(java.lang.String filePath)Returns a FileConfigBuilder to create a FileConfig with many options.static FileConfigBuilderbuilder(java.lang.String filePath, ConfigFormat<?> format)Returns a FileConfigBuilder to create a FileConfig with many options.static FileConfigBuilderbuilder(java.nio.file.Path file)Returns a FileConfigBuilder to create a FileConfig with many options.static FileConfigBuilderbuilder(java.nio.file.Path file, ConfigFormat<?> format)Returns a FileConfigBuilder to create a FileConfig with many options.default FileConfigchecked()Returns a checked view of the config.voidclose()Closes this FileConfig, releases its associated resources (if any), and ensure that the ongoing saving operations complete.java.io.FilegetFile()java.nio.file.PathgetNioPath()voidload()(Re)loads this config from the file.static FileConfigof(java.io.File file)Creates a new FileConfig based on the specified file.static FileConfigof(java.io.File file, ConfigFormat<? extends Config> format)Creates a new FileConfig based on the specified file and format.static FileConfigof(java.lang.String filePath)Creates a new FileConfig based on the specified file.static FileConfigof(java.lang.String filePath, ConfigFormat<?> format)Creates a new FileConfig based on the specified file and format.static FileConfigof(java.nio.file.Path file)Creates a new FileConfig based on the specified file.static FileConfigof(java.nio.file.Path file, ConfigFormat<? extends Config> format)Creates a new FileConfig based on the specified file and format.static FileConfigofConcurrent(java.io.File file)Creates a new thread-safe FileConfig based on the specified file.static FileConfigofConcurrent(java.io.File file, ConfigFormat<?> format)Creates a new thread-safe FileConfig based on the specified file and format.static FileConfigofConcurrent(java.lang.String filePath)Creates a new thread-safe FileConfig based on the specified file.static FileConfigofConcurrent(java.lang.String filePath, ConfigFormat<?> format)Creates a new thread-safe FileConfig based on the specified file and format.static FileConfigofConcurrent(java.nio.file.Path file)Creates a new thread-safe FileConfig based on the specified file.static FileConfigofConcurrent(java.nio.file.Path file, ConfigFormat<?> format)Creates a new thread-safe FileConfig based on the specified file and format.voidsave()Saves this config as soon as possible.-
Methods inherited from interface com.electronwill.nightconfig.core.Config
add, add, addAll, clear, createSubConfig, entrySet, putAll, remove, remove, removeAll, set, set, unmodifiable, update, update, valueMap
-
Methods inherited from interface com.electronwill.nightconfig.core.UnmodifiableConfig
apply, apply, configFormat, contains, contains, get, get, getByte, getByte, getByteOrElse, getByteOrElse, getChar, getChar, getCharOrElse, getCharOrElse, getEnum, getEnum, getEnum, getEnum, getEnumOrElse, getEnumOrElse, getEnumOrElse, getEnumOrElse, getEnumOrElse, getEnumOrElse, getEnumOrElse, getEnumOrElse, getInt, getInt, getIntOrElse, getIntOrElse, getIntOrElse, getIntOrElse, getLong, getLong, getLongOrElse, getLongOrElse, getLongOrElse, getLongOrElse, getOptional, getOptional, getOptionalEnum, getOptionalEnum, getOptionalEnum, getOptionalEnum, getOptionalInt, getOptionalInt, getOptionalLong, getOptionalLong, getOrElse, getOrElse, getOrElse, getOrElse, getRaw, getRaw, getShort, getShort, getShortOrElse, getShortOrElse, isEmpty, isNull, isNull, size
-
-
-
-
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()andload()will throw an IllegalStateException. Closing an aleady closed FileConfig has no effect.- Specified by:
closein interfacejava.lang.AutoCloseable
-
checked
default FileConfig checked()
Description copied from interface:ConfigReturns 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 theConfigFormat.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.
-
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 configformat- 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 configformat- 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 pathformat- 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 configformat- 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 configformat- 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 pathformat- 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 configformat- 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 configformat- 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 pathformat- the config's format- Returns:
- a new FileConfigBuilder that will build a FileConfig associated to the specified file
-
-