public interface ConcurrentConfig extends Config
com.electronwill.nightconfig.core.concurrent.Config.Entry| Modifier and Type | Method and Description |
|---|---|
default void |
bulkRead(java.util.function.Consumer<? super UnmodifiableConfig> action)
Performs multiple reads as a single atomic operation.
|
<R> R |
bulkRead(java.util.function.Function<? super UnmodifiableConfig,R> action)
Performs multiple reads as a single atomic operation and returns a value.
|
default void |
bulkUpdate(java.util.function.Consumer<? super Config> action)
Performs multiple reads and writes as a single atomic operation.
|
<R> R |
bulkUpdate(java.util.function.Function<? super Config,R> action)
Performs multiple reads and writes as a single atomic operation and returns a value.
|
ConcurrentConfig |
createSubConfig()
Creates a new configuration that is meant to be inserted into this config.
|
add, add, addAll, checked, clear, concurrentCopy, concurrentCopy, copy, copy, copy, copy, entrySet, getDefaultMapCreator, getDefaultMapCreator, inMemory, inMemoryConcurrent, inMemoryUniversal, inMemoryUniversalConcurrent, isInsertionOrderPreserved, of, of, ofConcurrent, putAll, remove, remove, removeAll, set, set, setInsertionOrderPreserved, unmodifiable, update, update, valueMap, wrapapply, 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<R> R bulkRead(java.util.function.Function<? super UnmodifiableConfig,R> action)
It is guaranteed that the content of the config, accessed through the provided "view", will not change during the entire operation. The configuration must be used exclusively through the object passed to the consumer (the "view"), not with the original reference. After the bulk operation, the view cannot be used anymore.
Here is an example:
String combined = config.bulkUpdate(conf -> {
String a = conf.get("a");
String b = conf.get("b");
return a + b;
// note that we use `conf` and not `config`!
});
R - the type of the function's resultaction - a function to execute on the configuration viewdefault void bulkRead(java.util.function.Consumer<? super UnmodifiableConfig> action)
It is guaranteed that the content of the config, accessed through the provided "view", will not change during the entire operation. The configuration must be used exclusively through the object passed to the consumer (the "view"), not with the original reference. After the bulk operation, the view cannot be used anymore.
Here is an example:
config.bulkRead(conf -> {
String a = conf.get("a");
String b = conf.get("b");
// note that we use `conf` and not `config`!
});
action - a function to execute on the configuration view<R> R bulkUpdate(java.util.function.Function<? super Config,R> action)
It is guaranteed that the content of the config, accessed through the provided "view", will not be concurrently modified by other threads during the entire bulk operation. The configuration must be used exclusively through the object passed to the consumer (the "view"), not with the original reference. After the bulk operation, the view cannot be used anymore.
Here is an example:
String combined = config.bulkUpdate(conf -> {
String a = conf.get("a");
String b = conf.get("b");
String combined = a + b;
conf.set("combined", combined);
return combined;
// note that we use `conf` and not `config`!
});
If you only have to read the configuration, prefer to use bulkRead(Function),
since it may provide a better performance.
R - the type of the function's resultaction - a function to execute on the configuration viewdefault void bulkUpdate(java.util.function.Consumer<? super Config> action)
It is guaranteed that the content of the config, accessed through the provided "view", will not be concurrently modified by other threads during the entire bulk operation. The configuration must be used exclusively through the object passed to the consumer (the "view"), not with the original reference. After the bulk operation, the view cannot be used anymore.
Here is an example:
config.bulkUpdate(conf -> {
String a = conf.get("a");
String b = conf.get("b");
String combined = a + b;
conf.set("combined", combined);
// note that we use `conf` and not `config`!
});
If you only have to read the configuration, prefer to use bulkRead(Consumer),
since it may provide a better performance.
action - a function to execute on the configuration viewConcurrentConfig createSubConfig()
Every sub-config must be created with this method, mixing
different types of sub-configs in ConcurrentConfigs is invalid.
createSubConfig in interface Config