Interface Config
- All Superinterfaces:
UnmodifiableConfig
- All Known Subinterfaces:
CommentedConfig,CommentedFileConfig,FileConfig
- All Known Implementing Classes:
AbstractCommentedConfig,AbstractConfig,CommentedConfigWrapper,ConfigWrapper,ConvertedCommentedConfig,ConvertedCommentedFileConfig,ConvertedConfig,ConvertedFileConfig,FakeCommentedConfig
A (modifiable) configuration that contains key/value mappings. Configurations are generally
not thread-safe.
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptiondefault booleanAdds a config value.booleanAdds a config value.default voidaddAll(UnmodifiableConfig config) Adds all the values of a config to this config, without replacing existing entries.default Configchecked()Returns a checked view of the config.voidclear()Removes all values from the config.static ConfigconcurrentCopy(UnmodifiableConfig config) Creates a new Config with the content of the given config.static ConfigconcurrentCopy(UnmodifiableConfig config, ConfigFormat<?> format) Creates a new Config with the content of the given config.static Configcopy(UnmodifiableConfig config) Creates a new Config with the content of the given config.static Configcopy(UnmodifiableConfig config, ConfigFormat<?> format) Creates a new Config with the content of the given config.static ConfigCreates a new Config with the content of the given config.static Configcopy(UnmodifiableConfig config, Supplier<Map<String, Object>> mapCreator, ConfigFormat<?> format) Creates a new Config with the content of the given config.Creates a new sub config of this config, as created when a subconfig's creation is implied byset(List, Object)oradd(List, Object).Set<? extends Config.Entry>entrySet()Returns a Set view of the config's entries.getDefaultMapCreator(boolean concurrent) Returns a map supplier that fullfills the given requirements.getDefaultMapCreator(boolean concurrent, boolean insertionOrderPreserved) Returns a map supplier that fulfills the given requirements.static ConfiginMemory()Creates a Config with formatInMemoryFormat.defaultInstance().static ConfigCreates a thread-safe Config with formatInMemoryFormat.defaultInstance().static ConfigCreates a Config with formatInMemoryFormat.withUniversalSupport().static ConfigCreates a thread-safe Config with formatInMemoryFormat.withUniversalSupport().static booleanChecks if the newly created configs keep the insertion order of their content.static Configof(ConfigFormat<? extends Config> format) Creates a Config of the given format.static ConfigCreates a Config backed by a certain kind of map, given by a supplier.static ConfigofConcurrent(ConfigFormat<? extends Config> format) Creates a thread-safe Config of the given format.default voidputAll(UnmodifiableConfig config) Copies all the values of a config into this config.default <T> TRemoves a value from the config.<T> TRemoves a value from the config.default voidremoveAll(UnmodifiableConfig config) Removes all the values of the given config from this config.default <T> TSets a config value.<T> TSets a config value.static voidsetInsertionOrderPreserved(boolean orderPreserved) Modifies the behavior of the new configurations with regards to the preservation of the order of config values.default UnmodifiableConfigReturns an Unmodifiable view of the config.default voidFor scala: sets a config value.default voidFor scala: sets a config value.valueMap()Returns a Map view of the config's values.static Configwrap(Map<String, Object> map, ConfigFormat<?> format) Creates a Config backed by a Map.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 Details
-
set
Sets a config value.- Type Parameters:
T- the type of the old value- Parameters:
path- the value's path, each part separated by a dot. Example "a.b.c"value- the value to set- Returns:
- the old value if any, or
null
-
set
Sets a config value.- 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
-
add
Adds a config value. The value is set iff there is no value associated with the given path.- Parameters:
path- the value's path, each element of the list is a different part of the path.value- the value to set- Returns:
- true if the value has been added, false if a value is already associated with the given path
-
add
Adds a config value. The value is set iff there is no value associated with the given path.- Parameters:
path- the value's path, each part separated by a dot. Example "a.b.c"value- the value to set- Returns:
- true if the value has been added, false if a value is already associated with the given path
-
addAll
Adds all the values of a config to this config, without replacing existing entries.- Parameters:
config- the source config
-
putAll
Copies all the values of a config into this config. Existing entries are replaced, missing entries are created.- Parameters:
config- the source config
-
remove
Removes a value from the config.- Type Parameters:
T- the type of the old value- Parameters:
path- the value's path, each part separated by a dot. Example "a.b.c"- Returns:
- the old value if any, or
null
-
remove
Removes a value from the 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.- Returns:
- the old value if any, or
null
-
removeAll
Removes all the values of the given config from this config.- Parameters:
config- the values to remove
-
clear
void clear()Removes all values from the config. -
unmodifiable
Returns an Unmodifiable view of the config. Any change to the original (modifiable) config is still reflected to the returned UnmodifiableConfig, so it's unmodifiable but not immutable.- Returns:
- an Unmodifiable view of the config.
-
checked
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 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.
- Returns:
- a checked view of the config.
-
valueMap
Returns a Map view of the config's values. Any change to the map is reflected in the config and vice-versa.- Specified by:
valueMapin interfaceUnmodifiableConfig- Returns:
- a Map view of the config's values.
-
entrySet
Set<? extends Config.Entry> entrySet()Returns a Set view of the config's entries. Any change to the set or to the entries is reflected in the config, and vice-versa.- Specified by:
entrySetin interfaceUnmodifiableConfig- Returns:
- a Set view of the config's entries.
-
createSubConfig
Config createSubConfig()Creates a new sub config of this config, as created when a subconfig's creation is implied byset(List, Object)oradd(List, Object).- Returns:
- a new sub config
-
update
For scala: sets a config value.- Parameters:
path- the value's path, each part separated by a dot. Example "a.b.c"value- the value to set- See Also:
-
update
For scala: sets a config value.- Parameters:
path- the value's path, each element of the list is a different part of the path.value- the value to set- See Also:
-
of
Creates a Config of the given format.- Parameters:
format- the config's format- Returns:
- a new empty config
-
of
Creates a Config backed by a certain kind of map, given by a supplier. If you wish all your configs to preserve insertion order, please have a look at the more practical settingsetInsertionOrderPreserved(boolean).- Parameters:
mapCreator- a supplier which will be called to create all backing maps for this config (including sub-configs)format- the config's format- Returns:
- a new config backed by the map
-
ofConcurrent
Creates a thread-safe Config of the given format.- Parameters:
format- the config's format- Returns:
- a new empty, thread-safe config
-
inMemory
Creates a Config with formatInMemoryFormat.defaultInstance().- Returns:
- a new empty config
-
inMemoryUniversal
Creates a Config with formatInMemoryFormat.withUniversalSupport().- Returns:
- a new empty config
-
inMemoryConcurrent
Creates a thread-safe Config with formatInMemoryFormat.defaultInstance().- Returns:
- a new empty config
-
inMemoryUniversalConcurrent
Creates a thread-safe Config with formatInMemoryFormat.withUniversalSupport().- Returns:
- a new empty config
-
wrap
Creates a Config backed by a Map. Any change to the map is reflected in the config and vice-versa. If you wish all your configs to preserve insertion order, please have a look at the more practical settingsetInsertionOrderPreserved(boolean).- Parameters:
map- the Map to useformat- the config's format- Returns:
- a new config backed by the map
-
copy
Creates a new Config with the content of the given config. The returned config will have the same format as the copied config.- Parameters:
config- the config to copy- Returns:
- a copy of the config
-
copy
Creates a new Config with the content of the given config. The returned config will have the same format as the copied config, and be backed by the given supplier. If you wish all your configs to preserve insertion order, please have a look at the more practical settingsetInsertionOrderPreserved(boolean).- Parameters:
config- the config to copymapCreator- a supplier which will be called to create all backing maps for this config (including sub-configs)- Returns:
- a copy of the config
- See Also:
-
copy
Creates a new Config with the content of the given config.- Parameters:
config- the config to copyformat- the config's format- Returns:
- a copy of the config
-
copy
static Config copy(UnmodifiableConfig config, Supplier<Map<String, Object>> mapCreator, ConfigFormat<?> format) Creates a new Config with the content of the given config. The returned config will be backed by the given map supplier. If you wish all your configs to preserve insertion order, please have a look at the more practical settingsetInsertionOrderPreserved(boolean).- Parameters:
config- the config to copymapCreator- a supplier which will be called to create all backing maps for this config (including sub-configs)format- the config's format- Returns:
- a copy of the config
- See Also:
-
concurrentCopy
Creates a new Config with the content of the given config. The returned config will have the same format as the copied config.- Parameters:
config- the config to copy- Returns:
- a thread-safe copy of the config
-
concurrentCopy
Creates a new Config with the content of the given config.- Parameters:
config- the config to copyformat- the config's format- Returns:
- a thread-safe copy of the config
-
isInsertionOrderPreserved
static boolean isInsertionOrderPreserved()Checks if the newly created configs keep the insertion order of their content. By default this is not the case. This can be controlled with the `nightconfig.ordered` system property or by callingsetInsertionOrderPreserved(boolean).This setting does not apply to configurations created from a Map, from another Config, or with a specific map supplier.
- Returns:
- true if the new configs preserve the insertion order of their values, false to give no guarantee about the values ordering.
-
setInsertionOrderPreserved
static void setInsertionOrderPreserved(boolean orderPreserved) Modifies the behavior of the new configurations with regards to the preservation of the order of config values.This setting does not apply to configurations created from a Map, from another Config, or with a specific map supplier.
- Parameters:
orderPreserved- true to make the new configs preserve the insertion order of their values, false to give no guarantee about the values ordering.- See Also:
-
getDefaultMapCreator
static <T> Supplier<Map<String,T>> getDefaultMapCreator(boolean concurrent, boolean insertionOrderPreserved) Returns a map supplier that fulfills the given requirements.- Parameters:
concurrent- true to make the maps thread-safeinsertionOrderPreserved- true to make the maps preserve the insertion order of values- Returns:
- a map supplier corresponding to the given settings
-
getDefaultMapCreator
Returns a map supplier that fullfills the given requirements. It preserves (or not) the insertion order of its values according toisInsertionOrderPreserved().- Parameters:
concurrent- true to make the maps thread-safe- Returns:
- a map supplier corresponding to the given settings
-