Class ConvertedCommentedConfig
- java.lang.Object
-
- com.electronwill.nightconfig.core.utils.UnmodifiableConfigWrapper<C>
-
- com.electronwill.nightconfig.core.utils.ConfigWrapper<C>
-
- com.electronwill.nightconfig.core.conversion.ConvertedCommentedConfig
-
- All Implemented Interfaces:
CommentedConfig,Config,UnmodifiableCommentedConfig,UnmodifiableConfig
public final class ConvertedCommentedConfig extends ConfigWrapper<C>
A Config's wrapper that converts the values that are read from and put into the config.
-
-
Nested Class Summary
-
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
-
Nested classes/interfaces inherited from interface com.electronwill.nightconfig.core.UnmodifiableConfig
UnmodifiableConfig.Entry
-
-
Field Summary
-
Fields inherited from class com.electronwill.nightconfig.core.utils.UnmodifiableConfigWrapper
config
-
-
Constructor Summary
Constructors Constructor Description ConvertedCommentedConfig(CommentedConfig config, ConversionTable readTable, ConversionTable writeTable, java.util.function.Predicate<java.lang.Class<?>> supportPredicate)Creates a new ConvertedConfig that uses two conversion tables.ConvertedCommentedConfig(CommentedConfig config, java.util.function.Function<java.lang.Object,java.lang.Object> readConversion, java.util.function.Function<java.lang.Object,java.lang.Object> writeConversion, java.util.function.Predicate<java.lang.Class<?>> supportPredicate)Creates a new ConvertedConfig that uses two custom conversion functions.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.ConfigFormat<?>configFormat()Returns the config's format.booleancontainsComment(java.util.List<java.lang.String> path)Checks if the config contains a comment at some path.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.java.lang.StringgetComment(java.util.List<java.lang.String> path)Gets a comment from the config.java.util.Map<java.lang.String,UnmodifiableCommentedConfig.CommentNode>getComments()Returns a Map containing a deep copy of all the comments in the config.<T> TgetRaw(java.util.List<java.lang.String> path)Gets a value from the config.voidputAllComments(UnmodifiableCommentedConfig commentedConfig)Puts the comments in the given config to this config.voidputAllComments(java.util.Map<java.lang.String,UnmodifiableCommentedConfig.CommentNode> comments)Puts the comments in the given map to this config.java.lang.StringremoveComment(java.util.List<java.lang.String> path)Removes a comment from the config.<T> Tset(java.util.List<java.lang.String> path, java.lang.Object value)Sets a config value.java.lang.StringsetComment(java.util.List<java.lang.String> path, java.lang.String comment)Sets a config comment.java.lang.StringtoString()java.util.Map<java.lang.String,java.lang.Object>valueMap()Returns a Map view of the config's values.-
Methods inherited from class com.electronwill.nightconfig.core.utils.ConfigWrapper
add, clear, remove
-
Methods inherited from class com.electronwill.nightconfig.core.utils.UnmodifiableConfigWrapper
contains, equals, hashCode, isEmpty, size
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.electronwill.nightconfig.core.CommentedConfig
checked, removeComment, setComment, unmodifiable
-
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, getComment, 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
-
ConvertedCommentedConfig
public ConvertedCommentedConfig(CommentedConfig config, ConversionTable readTable, ConversionTable writeTable, java.util.function.Predicate<java.lang.Class<?>> supportPredicate)
Creates a new ConvertedConfig that uses two conversion tables.- Parameters:
config- the config to wrapreadTable- the ConversionTable used for parse operations (like getValue)writeTable- the ConversionTable used for write operations (like setValue)supportPredicate- a Predicate that checks if a given class is supported by the ConvertedConfig
-
ConvertedCommentedConfig
public ConvertedCommentedConfig(CommentedConfig config, java.util.function.Function<java.lang.Object,java.lang.Object> readConversion, java.util.function.Function<java.lang.Object,java.lang.Object> writeConversion, java.util.function.Predicate<java.lang.Class<?>> supportPredicate)
Creates a new ConvertedConfig that uses two custom conversion functions.- Parameters:
config- the config to wrapreadConversion- the Function used for parse operations (like getValue)writeConversion- the Function used for write operations (like setValue)supportPredicate- a Predicate that checks if a given class is supported by the ConvertedConfig
-
-
Method Detail
-
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.
-
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.
-
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
-
clearComments
public void clearComments()
Description copied from interface:CommentedConfigRemoves all the comments from the config.- Specified by:
clearCommentsin interfaceCommentedConfig
-
getComments
public java.util.Map<java.lang.String,UnmodifiableCommentedConfig.CommentNode> getComments()
Description copied from interface:UnmodifiableCommentedConfigReturns a Map containing a deep copy of all the comments in the config.- Specified by:
getCommentsin interfaceUnmodifiableCommentedConfig- Returns:
- a Map containing the comments in the config.
-
putAllComments
public void putAllComments(java.util.Map<java.lang.String,UnmodifiableCommentedConfig.CommentNode> comments)
Description copied from interface:CommentedConfigPuts the comments in the given map to this config. Existing comments are replaced, missing comments are created.- Specified by:
putAllCommentsin interfaceCommentedConfig- Parameters:
comments- the comments to set
-
putAllComments
public void putAllComments(UnmodifiableCommentedConfig commentedConfig)
Description copied from interface:CommentedConfigPuts the comments in the given config to this config. Existing comments are replaced, missing comments are created.- Specified by:
putAllCommentsin interfaceCommentedConfig- Parameters:
commentedConfig- the config to copy its comments
-
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:UnmodifiableConfigReturns a Set view of the config's entries. If the config is unmodifiable then the returned set is unmodifiable too.- Specified by:
entrySetin interfaceCommentedConfig- Specified by:
entrySetin interfaceConfig- Specified by:
entrySetin interfaceUnmodifiableCommentedConfig- Specified by:
entrySetin interfaceUnmodifiableConfig- Overrides:
entrySetin classConfigWrapper<C extends CommentedConfig>- Returns:
- a Set view of the config's entries.
-
createSubConfig
public 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 interfaceCommentedConfig- Specified by:
createSubConfigin interfaceConfig- Overrides:
createSubConfigin classConfigWrapper<C extends CommentedConfig>- Returns:
- a new sub config
-
set
public <T> T set(java.util.List<java.lang.String> path, java.lang.Object value)Description copied from interface:ConfigSets a config value.- Specified by:
setin interfaceConfig- Overrides:
setin classConfigWrapper<C extends 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.value- the value to set- Returns:
- the old value if any, or
null
-
valueMap
public java.util.Map<java.lang.String,java.lang.Object> valueMap()
Description copied from interface:UnmodifiableConfigReturns a Map view of the config's values. If the config is unmodifiable then the returned map is unmodifiable too.- Specified by:
valueMapin interfaceConfig- Specified by:
valueMapin interfaceUnmodifiableConfig- Overrides:
valueMapin classUnmodifiableConfigWrapper<C extends Config>- Returns:
- a Map view of the config's values.
-
getRaw
public <T> T getRaw(java.util.List<java.lang.String> path)
Description copied from interface:UnmodifiableConfigGets a value from the config. Doesn't convertNullObject.NULL_OBJECTtonull.- Specified by:
getRawin interfaceUnmodifiableConfig- Overrides:
getRawin classUnmodifiableConfigWrapper<C extends Config>- Type Parameters:
T- the value's type- Parameters:
path- the value's path, each element of the list is a different part of the path.- Returns:
- the value at the given path, or
nullif there is no such value.
-
configFormat
public ConfigFormat<?> configFormat()
Description copied from interface:UnmodifiableConfigReturns the config's format.- Specified by:
configFormatin interfaceUnmodifiableConfig- Overrides:
configFormatin classUnmodifiableConfigWrapper<C extends Config>- Returns:
- the config's format
-
toString
public java.lang.String toString()
- Overrides:
toStringin classConfigWrapper<C extends Config>
-
-