Class ConvertedFileConfig
- java.lang.Object
-
- com.electronwill.nightconfig.core.utils.UnmodifiableConfigWrapper<C>
-
- com.electronwill.nightconfig.core.utils.ConfigWrapper<C>
-
- com.electronwill.nightconfig.core.conversion.ConvertedFileConfig
-
- All Implemented Interfaces:
Config,FileConfig,UnmodifiableConfig,java.lang.AutoCloseable
public class ConvertedFileConfig extends ConfigWrapper<C> implements FileConfig
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.electronwill.nightconfig.core.Config
Config.Entry
-
Nested classes/interfaces inherited from interface com.electronwill.nightconfig.core.UnmodifiableConfig
UnmodifiableConfig.Entry
-
-
Field Summary
-
Fields inherited from class com.electronwill.nightconfig.core.utils.UnmodifiableConfigWrapper
config
-
-
Constructor Summary
Constructors Constructor Description ConvertedFileConfig(FileConfig config, ConversionTable readTable, ConversionTable writeTable, java.util.function.Predicate<java.lang.Class<?>> supportPredicate)ConvertedFileConfig(FileConfig config, java.util.function.Function<java.lang.Object,java.lang.Object> readConversion, java.util.function.Function<java.lang.Object,java.lang.Object> writeConversion, java.util.function.Predicate<java.lang.Class<?>> supportPredicate)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Closes this FileConfig, releases its associated resources (if any), and ensure that the ongoing saving operations complete.ConfigFormat<?>configFormat()Returns the config's format.java.io.FilegetFile()java.nio.file.PathgetNioPath()<T> TgetRaw(java.util.List<java.lang.String> path)Gets a value from the config.voidload()(Re)loads this config from the file.voidsave()Saves this config as soon as possible.<T> Tset(java.util.List<java.lang.String> path, java.lang.Object value)Sets a config value.java.lang.StringtoString()java.util.Map<java.lang.String,java.lang.Object>valueMap()Returns a Map view of the config's values.-
Methods inherited from class com.electronwill.nightconfig.core.utils.ConfigWrapper
add, clear, createSubConfig, entrySet, remove
-
Methods inherited from class com.electronwill.nightconfig.core.utils.UnmodifiableConfigWrapper
contains, equals, hashCode, isEmpty, size
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
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.file.FileConfig
checked
-
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
-
-
-
-
Constructor Detail
-
ConvertedFileConfig
public ConvertedFileConfig(FileConfig config, ConversionTable readTable, ConversionTable writeTable, java.util.function.Predicate<java.lang.Class<?>> supportPredicate)
-
ConvertedFileConfig
public ConvertedFileConfig(FileConfig config, java.util.function.Function<java.lang.Object,java.lang.Object> readConversion, java.util.function.Function<java.lang.Object,java.lang.Object> writeConversion, java.util.function.Predicate<java.lang.Class<?>> supportPredicate)
-
-
Method Detail
-
getFile
public java.io.File getFile()
- Specified by:
getFilein interfaceFileConfig- Returns:
- the config's file, as a classic File object
-
getNioPath
public java.nio.file.Path getNioPath()
- Specified by:
getNioPathin interfaceFileConfig- Returns:
- the config's file, as a NIO Path object
-
save
public void save()
Description copied from interface:FileConfigSaves 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.- Specified by:
savein interfaceFileConfig
-
load
public void load()
Description copied from interface:FileConfig(Re)loads this config from the file. This method blocks until the read operation completes.- Specified by:
loadin interfaceFileConfig
-
close
public void close()
Description copied from interface:FileConfigCloses 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
FileConfig.save()andFileConfig.load()will throw an IllegalStateException. Closing an aleady closed FileConfig has no effect.- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfaceFileConfig
-
set
public <T> T set(java.util.List<java.lang.String> path, java.lang.Object value)Description copied from interface:ConfigSets a config value.- Specified by:
setin interfaceConfig- Overrides:
setin classConfigWrapper<C extends Config>- Type Parameters:
T- the type of the old value- Parameters:
path- the value's path, each element of the list is a different part of the path.value- the value to set- Returns:
- the old value if any, or
null
-
valueMap
public java.util.Map<java.lang.String,java.lang.Object> valueMap()
Description copied from interface:UnmodifiableConfigReturns a Map view of the config's values. If the config is unmodifiable then the returned map is unmodifiable too.- Specified by:
valueMapin interfaceConfig- Specified by:
valueMapin interfaceUnmodifiableConfig- Overrides:
valueMapin classUnmodifiableConfigWrapper<C extends Config>- Returns:
- a Map view of the config's values.
-
getRaw
public <T> T getRaw(java.util.List<java.lang.String> path)
Description copied from interface:UnmodifiableConfigGets a value from the config. Doesn't convertNullObject.NULL_OBJECTtonull.- Specified by:
getRawin interfaceUnmodifiableConfig- Overrides:
getRawin classUnmodifiableConfigWrapper<C extends Config>- Type Parameters:
T- the value's type- Parameters:
path- the value's path, each element of the list is a different part of the path.- Returns:
- the value at the given path, or
nullif there is no such value.
-
configFormat
public ConfigFormat<?> configFormat()
Description copied from interface:UnmodifiableConfigReturns the config's format.- Specified by:
configFormatin interfaceUnmodifiableConfig- Overrides:
configFormatin classUnmodifiableConfigWrapper<C extends Config>- Returns:
- the config's format
-
toString
public java.lang.String toString()
- Overrides:
toStringin classConfigWrapper<C extends Config>
-
-