Interface FileConfig
- All Superinterfaces:
AutoCloseable,Config,UnmodifiableConfig
- All Known Subinterfaces:
CommentedFileConfig
- All Known Implementing Classes:
ConvertedCommentedFileConfig,ConvertedFileConfig
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.electronwill.nightconfig.core.Config
Config.Entry -
Method Summary
Modifier and TypeMethodDescriptionstatic FileConfigBuilderReturns a FileConfigBuilder to create a FileConfig with many options.static FileConfigBuilderbuilder(File file, ConfigFormat<?> format) Returns a FileConfigBuilder to create a FileConfig with many options.static FileConfigBuilderReturns a FileConfigBuilder to create a FileConfig with many options.static FileConfigBuilderbuilder(String filePath, ConfigFormat<?> format) Returns a FileConfigBuilder to create a FileConfig with many options.static FileConfigBuilderReturns a FileConfigBuilder to create a FileConfig with many options.static FileConfigBuilderbuilder(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.getFile()voidload()(Re)loads this config from the file.static FileConfigCreates a new FileConfig based on the specified file.static FileConfigof(File file, ConfigFormat<? extends Config> format) Creates a new FileConfig based on the specified file and format.static FileConfigCreates a new FileConfig based on the specified file.static FileConfigof(String filePath, ConfigFormat<?> format) Creates a new FileConfig based on the specified file and format.static FileConfigCreates a new FileConfig based on the specified file.static FileConfigof(Path file, ConfigFormat<? extends Config> format) Creates a new FileConfig based on the specified file and format.static FileConfigofConcurrent(File file) Creates a new thread-safe FileConfig based on the specified file.static FileConfigofConcurrent(File file, ConfigFormat<?> format) Creates a new thread-safe FileConfig based on the specified file and format.static FileConfigofConcurrent(String filePath) Creates a new thread-safe FileConfig based on the specified file.static FileConfigofConcurrent(String filePath, ConfigFormat<?> format) Creates a new thread-safe FileConfig based on the specified file and format.static FileConfigofConcurrent(Path file) Creates a new thread-safe FileConfig based on the specified file.static FileConfigofConcurrent(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, valueMapMethods 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 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()andload()will throw an IllegalStateException. Closing an aleady closed FileConfig has no effect.- Specified by:
closein interfaceAutoCloseable
-
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
-