Class AbstractCommentedConfig
- java.lang.Object
-
- com.electronwill.nightconfig.core.AbstractConfig
-
- com.electronwill.nightconfig.core.AbstractCommentedConfig
-
- All Implemented Interfaces:
CommentedConfig,Config,UnmodifiableCommentedConfig,UnmodifiableConfig,java.lang.Cloneable
public abstract class AbstractCommentedConfig extends AbstractConfig implements CommentedConfig
An abstract CommentedConfig backed by two maps: one for the values and one for the comments. The comments of the subconfigs are stored in these subconfigs.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classAbstractCommentedConfig.CommentedEntryWrapper-
Nested classes/interfaces inherited from class com.electronwill.nightconfig.core.AbstractConfig
AbstractConfig.EntryWrapper
-
Nested classes/interfaces inherited from interface com.electronwill.nightconfig.core.CommentedConfig
CommentedConfig.Entry
-
Nested classes/interfaces inherited from interface com.electronwill.nightconfig.core.Config
Config.Entry
-
Nested classes/interfaces inherited from interface com.electronwill.nightconfig.core.UnmodifiableCommentedConfig
UnmodifiableCommentedConfig.CommentNode
-
-
Field Summary
-
Fields inherited from class com.electronwill.nightconfig.core.AbstractConfig
mapCreator
-
-
Constructor Summary
Constructors Constructor Description AbstractCommentedConfig(boolean concurrent)AbstractCommentedConfig(UnmodifiableCommentedConfig toCopy, boolean concurrent)Creates an AbstractCommentedConfig that is a copy of the specified config.AbstractCommentedConfig(UnmodifiableCommentedConfig toCopy, java.util.function.Supplier<java.util.Map<java.lang.String,java.lang.Object>> mapCreator)AbstractCommentedConfig(UnmodifiableConfig toCopy, boolean concurrent)Creates an AbstractCommentedConfig that is a copy of the specified config.AbstractCommentedConfig(UnmodifiableConfig toCopy, java.util.function.Supplier<java.util.Map<java.lang.String,java.lang.Object>> mapCreator)AbstractCommentedConfig(java.util.function.Supplier<java.util.Map<java.lang.String,java.lang.Object>> mapCreator)AbstractCommentedConfig(java.util.Map<java.lang.String,java.lang.Object> valuesMap)Creates an AbstractCommentedConfig backed by the specified map
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidclear()Removes all values from the config.voidclearComments()Removes all the comments from the config.abstract AbstractCommentedConfigclone()Creates and return a copy of this config.java.util.Map<java.lang.String,java.lang.String>commentMap()Returns a Map view of the config's comments.booleancontainsComment(java.util.List<java.lang.String> path)Checks if the config contains a comment at some path.java.util.Set<? extends CommentedConfig.Entry>entrySet()Returns a Set view of the config's entries.java.lang.StringgetComment(java.util.List<java.lang.String> path)Gets a comment from the config.protected static java.util.Map<java.lang.String,java.lang.String>getDefaultCommentMap(boolean concurrent)java.lang.StringremoveComment(java.util.List<java.lang.String> path)Removes a comment from the config.java.lang.StringsetComment(java.util.List<java.lang.String> path, java.lang.String comment)Sets a config comment.-
Methods inherited from class com.electronwill.nightconfig.core.AbstractConfig
add, contains, equals, getDefaultMapCreator, getRaw, getWildcardMapCreator, hashCode, isNull, remove, set, size, toString, valueMap
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.electronwill.nightconfig.core.CommentedConfig
checked, createSubConfig, putAllComments, putAllComments, removeComment, setComment, unmodifiable
-
Methods inherited from interface com.electronwill.nightconfig.core.Config
add, add, addAll, putAll, remove, remove, removeAll, set, set, update, update, valueMap
-
Methods inherited from interface com.electronwill.nightconfig.core.UnmodifiableCommentedConfig
containsComment, 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
-
-
-
-
Constructor Detail
-
AbstractCommentedConfig
public AbstractCommentedConfig(boolean concurrent)
-
AbstractCommentedConfig
public AbstractCommentedConfig(java.util.function.Supplier<java.util.Map<java.lang.String,java.lang.Object>> mapCreator)
-
AbstractCommentedConfig
public AbstractCommentedConfig(java.util.Map<java.lang.String,java.lang.Object> valuesMap)
Creates an AbstractCommentedConfig backed by the specified map- Parameters:
valuesMap- the map containing the config's values
-
AbstractCommentedConfig
public AbstractCommentedConfig(UnmodifiableConfig toCopy, boolean concurrent)
Creates an AbstractCommentedConfig that is a copy of the specified config.- Parameters:
toCopy- the config to copy
-
AbstractCommentedConfig
public AbstractCommentedConfig(UnmodifiableConfig toCopy, java.util.function.Supplier<java.util.Map<java.lang.String,java.lang.Object>> mapCreator)
-
AbstractCommentedConfig
public AbstractCommentedConfig(UnmodifiableCommentedConfig toCopy, boolean concurrent)
Creates an AbstractCommentedConfig that is a copy of the specified config.- Parameters:
toCopy- the config to copy
-
AbstractCommentedConfig
public AbstractCommentedConfig(UnmodifiableCommentedConfig toCopy, java.util.function.Supplier<java.util.Map<java.lang.String,java.lang.Object>> mapCreator)
-
-
Method Detail
-
getDefaultCommentMap
protected static java.util.Map<java.lang.String,java.lang.String> getDefaultCommentMap(boolean concurrent)
-
getComment
public java.lang.String getComment(java.util.List<java.lang.String> path)
Description copied from interface:UnmodifiableCommentedConfigGets a comment from the config.- Specified by:
getCommentin interfaceUnmodifiableCommentedConfig- Parameters:
path- the comment's path, each element of the list is a different part of the path.- Returns:
- the comment at the given path, or
nullif there is none.
-
setComment
public java.lang.String setComment(java.util.List<java.lang.String> path, java.lang.String comment)Description copied from interface:CommentedConfigSets a config comment.- Specified by:
setCommentin interfaceCommentedConfig- 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
public java.lang.String removeComment(java.util.List<java.lang.String> path)
Description copied from interface:CommentedConfigRemoves a comment from the config.- Specified by:
removeCommentin interfaceCommentedConfig- 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
-
containsComment
public boolean containsComment(java.util.List<java.lang.String> path)
Description copied from interface:UnmodifiableCommentedConfigChecks if the config contains a comment at some path.- Specified by:
containsCommentin interfaceUnmodifiableCommentedConfig- Parameters:
path- the path to check, each element of the list is a different part of the path.- Returns:
trueif the path is associated with a comment,falseif it's not.
-
commentMap
public java.util.Map<java.lang.String,java.lang.String> commentMap()
Description copied from interface:CommentedConfigReturns 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 interfaceCommentedConfig- Specified by:
commentMapin interfaceUnmodifiableCommentedConfig- Returns:
- a Map view of the config's comments.
-
entrySet
public java.util.Set<? extends CommentedConfig.Entry> entrySet()
Description copied from interface:ConfigReturns 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 interfaceCommentedConfig- Specified by:
entrySetin interfaceConfig- Specified by:
entrySetin interfaceUnmodifiableCommentedConfig- Specified by:
entrySetin interfaceUnmodifiableConfig- Overrides:
entrySetin classAbstractConfig- Returns:
- a Set view of the config's entries.
-
clone
public abstract AbstractCommentedConfig clone()
Description copied from class:AbstractConfigCreates and return a copy of this config.- Specified by:
clonein classAbstractConfig- Returns:
- a new config that contains the same entries (including comments) as this config.
-
clear
public void clear()
Description copied from interface:ConfigRemoves all values from the config.- Specified by:
clearin interfaceConfig- Overrides:
clearin classAbstractConfig
-
clearComments
public void clearComments()
Description copied from interface:CommentedConfigRemoves all the comments from the config.- Specified by:
clearCommentsin interfaceCommentedConfig
-
-