Interface CommentedConfig
-
- All Superinterfaces:
Config,UnmodifiableCommentedConfig,UnmodifiableConfig
- All Known Subinterfaces:
CommentedFileConfig
- All Known Implementing Classes:
AbstractCommentedConfig,CommentedConfigWrapper,ConvertedCommentedConfig,ConvertedCommentedFileConfig,FakeCommentedConfig
public interface CommentedConfig extends UnmodifiableCommentedConfig, Config
A modifiable config that supports comments.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceCommentedConfig.EntryA modifiable commented config entry.-
Nested classes/interfaces inherited from interface com.electronwill.nightconfig.core.UnmodifiableCommentedConfig
UnmodifiableCommentedConfig.CommentNode
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default CommentedConfigchecked()Returns a checked view of the config.voidclearComments()Removes all the comments from the config.java.util.Map<java.lang.String,java.lang.String>commentMap()Returns a Map view of the config's comments.static CommentedConfigconcurrentCopy(UnmodifiableCommentedConfig config)Creates 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 CommentedConfigcopy(UnmodifiableCommentedConfig config, java.util.function.Supplier<java.util.Map<java.lang.String,java.lang.Object>> mapCreator)Creates a new CommentedConfig with the content of the given config.static CommentedConfigcopy(UnmodifiableCommentedConfig config, java.util.function.Supplier<java.util.Map<java.lang.String,java.lang.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 CommentedConfigcopy(UnmodifiableConfig config, java.util.function.Supplier<java.util.Map<java.lang.String,java.lang.Object>> mapCreator)Creates a new CommentedConfig with the content of the given config.static CommentedConfigcopy(UnmodifiableConfig config, java.util.function.Supplier<java.util.Map<java.lang.String,java.lang.Object>> mapCreator, ConfigFormat<?> format)Creates a new CommentedConfig with the content of the given config.CommentedConfigcreateSubConfig()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).java.util.Set<? extends CommentedConfig.Entry>entrySet()Returns a Set view of the config's entries.static CommentedConfigfake(Config config)If the specified config is an instance of CommentedConfig, returns it.static CommentedConfiginMemory()Creates a CommentedConfig with formatInMemoryCommentedFormat.defaultInstance().static CommentedConfiginMemoryConcurrent()Creates a CommentedConfig with formatInMemoryFormat.defaultInstance().static CommentedConfigof(ConfigFormat<? extends CommentedConfig> format)Creates a CommentedConfig of the given format.static CommentedConfigof(java.util.function.Supplier<java.util.Map<java.lang.String,java.lang.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 voidputAllComments(java.util.Map<java.lang.String,UnmodifiableCommentedConfig.CommentNode> comments)Puts the comments in the given map to this config.default java.lang.StringremoveComment(java.lang.String path)Removes a comment from the config.java.lang.StringremoveComment(java.util.List<java.lang.String> path)Removes a comment from the config.default java.lang.StringsetComment(java.lang.String path, java.lang.String comment)Sets a config comment.java.lang.StringsetComment(java.util.List<java.lang.String> path, java.lang.String comment)Sets a config comment.default UnmodifiableCommentedConfigunmodifiable()Returns an Unmodifiable view of the config.static CommentedConfigwrap(java.util.Map<java.lang.String,java.lang.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, valueMap
-
Methods inherited from interface com.electronwill.nightconfig.core.UnmodifiableCommentedConfig
containsComment, containsComment, getComment, getComment, getComments, getComments, getOptionalComment, getOptionalComment
-
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 Detail
-
setComment
default java.lang.String setComment(java.lang.String path, java.lang.String comment)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
java.lang.String setComment(java.util.List<java.lang.String> path, java.lang.String comment)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
default java.lang.String removeComment(java.lang.String path)
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
java.lang.String removeComment(java.util.List<java.lang.String> path)
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
default void putAllComments(java.util.Map<java.lang.String,UnmodifiableCommentedConfig.CommentNode> comments)
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
default void putAllComments(UnmodifiableCommentedConfig commentedConfig)
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
default UnmodifiableCommentedConfig 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
default CommentedConfig 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
java.util.Map<java.lang.String,java.lang.String> 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
java.util.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
static CommentedConfig of(ConfigFormat<? extends CommentedConfig> format)
Creates a CommentedConfig of the given format.- Parameters:
format- the config's format- Returns:
- a new empty config
-
of
static CommentedConfig of(java.util.function.Supplier<java.util.Map<java.lang.String,java.lang.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
static CommentedConfig ofConcurrent(ConfigFormat<? extends CommentedConfig> format)
Creates a thread-safe CommentedConfig of the given format.- Parameters:
format- the config's format- Returns:
- a new empty, thread-safe config
-
inMemory
static CommentedConfig inMemory()
Creates a CommentedConfig with formatInMemoryCommentedFormat.defaultInstance().- Returns:
- a new empty config
-
inMemoryConcurrent
static CommentedConfig inMemoryConcurrent()
Creates a CommentedConfig with formatInMemoryFormat.defaultInstance().- Returns:
- a new empty config
-
wrap
static CommentedConfig wrap(java.util.Map<java.lang.String,java.lang.Object> map, ConfigFormat<?> format)
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
static CommentedConfig copy(UnmodifiableConfig config)
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(UnmodifiableConfig config, java.util.function.Supplier<java.util.Map<java.lang.String,java.lang.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, 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:
of(Supplier, ConfigFormat)
-
copy
static CommentedConfig copy(UnmodifiableConfig config, ConfigFormat<?> format)
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, java.util.function.Supplier<java.util.Map<java.lang.String,java.lang.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:
of(Supplier, ConfigFormat)
-
copy
static CommentedConfig copy(UnmodifiableCommentedConfig config)
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, java.util.function.Supplier<java.util.Map<java.lang.String,java.lang.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
static CommentedConfig copy(UnmodifiableCommentedConfig config, ConfigFormat<?> format)
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, java.util.function.Supplier<java.util.Map<java.lang.String,java.lang.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:
of(Supplier, ConfigFormat)
-
concurrentCopy
static CommentedConfig concurrentCopy(UnmodifiableConfig config)
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
static CommentedConfig concurrentCopy(UnmodifiableConfig config, ConfigFormat<?> format)
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
static CommentedConfig concurrentCopy(UnmodifiableCommentedConfig config)
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
static CommentedConfig concurrentCopy(UnmodifiableCommentedConfig config, ConfigFormat<?> format)
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
static CommentedConfig fake(Config config)
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
-
-