Interface CommentedConfig
- All Superinterfaces:
Config,UnmodifiableCommentedConfig,UnmodifiableConfig
- All Known Subinterfaces:
CommentedFileConfig
- All Known Implementing Classes:
AbstractCommentedConfig,CommentedConfigWrapper,ConvertedCommentedConfig,ConvertedCommentedFileConfig,FakeCommentedConfig
A modifiable config that supports comments.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceA modifiable commented config entry.Nested classes/interfaces inherited from interface com.electronwill.nightconfig.core.UnmodifiableCommentedConfig
UnmodifiableCommentedConfig.CommentNode -
Method Summary
Modifier and TypeMethodDescriptiondefault CommentedConfigchecked()Returns a checked view of the config.voidRemoves all the comments from the config.Returns a Map view of the config's comments.static CommentedConfigCreates a new CommentedConfig with the content of the given config.static CommentedConfigconcurrentCopy(UnmodifiableCommentedConfig config, ConfigFormat<?> format) Creates a new CommentedConfig with the content of the given config.static CommentedConfigconcurrentCopy(UnmodifiableConfig config) Creates a new CommentedConfig with the content of the given config.static CommentedConfigconcurrentCopy(UnmodifiableConfig config, ConfigFormat<?> format) Creates a new CommentedConfig with the content of the given config.static CommentedConfigcopy(UnmodifiableCommentedConfig config) Creates a new CommentedConfig with the content of the given config.static CommentedConfigcopy(UnmodifiableCommentedConfig config, ConfigFormat<?> format) Creates a new CommentedConfig with the content of the given config.static CommentedConfigCreates a new CommentedConfig with the content of the given config.static CommentedConfigcopy(UnmodifiableCommentedConfig config, Supplier<Map<String, Object>> mapCreator, ConfigFormat<? extends CommentedConfig> format) Creates a new CommentedConfig with the content of the given config.static CommentedConfigcopy(UnmodifiableConfig config) Creates a new CommentedConfig with the content of the given config.static CommentedConfigcopy(UnmodifiableConfig config, ConfigFormat<?> format) Creates a new CommentedConfig with the content of the given config.static CommentedConfigCreates a new CommentedConfig with the content of the given config.static CommentedConfigcopy(UnmodifiableConfig config, Supplier<Map<String, Object>> mapCreator, ConfigFormat<?> format) Creates a new CommentedConfig with the content of the given config.Creates a new sub config of this config, as created when a subconfig's creation is implied byConfig.set(List, Object)orConfig.add(List, Object).Set<? extends CommentedConfig.Entry>entrySet()Returns a Set view of the config's entries.static CommentedConfigIf the specified config is an instance of CommentedConfig, returns it.static CommentedConfiginMemory()Creates a CommentedConfig with formatInMemoryCommentedFormat.defaultInstance().static CommentedConfigCreates a CommentedConfig with formatInMemoryFormat.defaultInstance().static CommentedConfigof(ConfigFormat<? extends CommentedConfig> format) Creates a CommentedConfig of the given format.static CommentedConfigof(Supplier<Map<String, Object>> mapCreator, ConfigFormat<? extends CommentedConfig> format) Creates a Config backed by a certain kind of map, given by a supplier.static CommentedConfigofConcurrent(ConfigFormat<? extends CommentedConfig> format) Creates a thread-safe CommentedConfig of the given format.default voidputAllComments(UnmodifiableCommentedConfig commentedConfig) Puts the comments in the given config to this config.default voidPuts the comments in the given map to this config.default StringremoveComment(String path) Removes a comment from the config.removeComment(List<String> path) Removes a comment from the config.default StringsetComment(String path, String comment) Sets a config comment.setComment(List<String> path, String comment) Sets a config comment.default UnmodifiableCommentedConfigReturns an Unmodifiable view of the config.static CommentedConfigwrap(Map<String, Object> map, ConfigFormat<?> format) Creates a CommentedConfig backed by a Map.Methods inherited from interface com.electronwill.nightconfig.core.Config
add, add, addAll, clear, putAll, remove, remove, removeAll, set, set, update, update, valueMapMethods inherited from interface com.electronwill.nightconfig.core.UnmodifiableCommentedConfig
containsComment, containsComment, getComment, getComment, getComments, getComments, getOptionalComment, getOptionalCommentMethods 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
-
setComment
Sets a config comment.- Parameters:
path- the comment's path, each part separated by a dot. Example "a.b.c"comment- the comment to set- Returns:
- the old comment if any, or
null
-
setComment
Sets a config comment.- Parameters:
path- the comment's path, each element of the list is a different part of the path.comment- the comment to set- Returns:
- the old comment if any, or
null
-
removeComment
Removes a comment from the config.- Parameters:
path- the comment's path, each part separated by a dot. Example "a.b.c"- Returns:
- the old comment if any, or
null
-
removeComment
Removes a comment from the config.- Parameters:
path- the comment's path, each element of the list is a different part of the path.- Returns:
- the old comment if any, or
null
-
clearComments
void clearComments()Removes all the comments from the config. -
putAllComments
Puts the comments in the given map to this config. Existing comments are replaced, missing comments are created.- Parameters:
comments- the comments to set
-
putAllComments
Puts the comments in the given config to this config. Existing comments are replaced, missing comments are created.- Parameters:
commentedConfig- the config to copy its comments
-
unmodifiable
Description copied from interface:ConfigReturns 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.- Specified by:
unmodifiablein interfaceConfig- Returns:
- an Unmodifiable view of the config.
-
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.
-
commentMap
Returns a Map view of the config's comments. Any change to the map is reflected in the config and vice-versa.The comment map contains only the comments of the direct elements of the configuration, not the comments of their sub-elements.
- Specified by:
commentMapin interfaceUnmodifiableCommentedConfig- Returns:
- a Map view of the config's comments.
-
entrySet
Set<? extends CommentedConfig.Entry> entrySet()Description copied from interface:UnmodifiableConfigReturns a Set view of the config's entries. If the config is unmodifiable then the returned set is unmodifiable too.- Specified by:
entrySetin interfaceConfig- Specified by:
entrySetin interfaceUnmodifiableCommentedConfig- Specified by:
entrySetin interfaceUnmodifiableConfig- Returns:
- a Set view of the config's entries.
-
createSubConfig
CommentedConfig createSubConfig()Description copied from interface:ConfigCreates a new sub config of this config, as created when a subconfig's creation is implied byConfig.set(List, Object)orConfig.add(List, Object).- Specified by:
createSubConfigin interfaceConfig- Returns:
- a new sub config
-
of
Creates a CommentedConfig of the given format.- Parameters:
format- the config's format- Returns:
- a new empty config
-
of
static CommentedConfig of(Supplier<Map<String, Object>> mapCreator, ConfigFormat<? extends CommentedConfig> format) Creates a Config backed by a certain kind of map, given by a supplier.- 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 empty config
-
ofConcurrent
Creates a thread-safe CommentedConfig of the given format.- Parameters:
format- the config's format- Returns:
- a new empty, thread-safe config
-
inMemory
Creates a CommentedConfig with formatInMemoryCommentedFormat.defaultInstance().- Returns:
- a new empty config
-
inMemoryConcurrent
Creates a CommentedConfig with formatInMemoryFormat.defaultInstance().- Returns:
- a new empty config
-
wrap
Creates a CommentedConfig backed by a Map. Any change to the map is reflected in the config and vice-versa.- Parameters:
map- the Map to useformat- the config's format- Returns:
- a new config backed by the map
-
copy
Creates a new CommentedConfig 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 CommentedConfig 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.- 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 CommentedConfig 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 CommentedConfig copy(UnmodifiableConfig config, Supplier<Map<String, Object>> mapCreator, ConfigFormat<?> format) Creates a new CommentedConfig with the content of the given config. The returned config will be backed by the given map supplier.- 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:
-
copy
Creates a new CommentedConfig 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
static CommentedConfig copy(UnmodifiableCommentedConfig config, Supplier<Map<String, Object>> mapCreator) Creates a new CommentedConfig with the content of the given config. The returned config will have the same format as the copied config.- 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
-
copy
Creates a new CommentedConfig 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 CommentedConfig copy(UnmodifiableCommentedConfig config, Supplier<Map<String, Object>> mapCreator, ConfigFormat<? extends CommentedConfig> format) Creates a new CommentedConfig with the content of the given config. The returned config will be backed by the given map supplier.- 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 CommentedConfig 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 CommentedConfig 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
-
concurrentCopy
Creates a new CommentedConfig 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 CommentedConfig 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
-
fake
If the specified config is an instance of CommentedConfig, returns it. Else, returns a "fake" CommentedConfig instance with the same values (ie the valueMaps are equal) as the config. This fake CommentedConfig doesn't actually store nor process comments, it just provides the methods of CommentedConfig.- Parameters:
config- the config- Returns:
- a CommentedConfig instance backed by the specified config
-