public final class ConvertedCommentedFileConfig extends ConfigWrapper<C> implements CommentedFileConfig
CommentedConfig.EntryUnmodifiableCommentedConfig.CommentNodeconfig| Constructor and Description |
|---|
ConvertedCommentedFileConfig(CommentedFileConfig config,
ConversionTable readTable,
ConversionTable writeTable,
java.util.function.Predicate<java.lang.Class<?>> supportPredicate) |
ConvertedCommentedFileConfig(CommentedFileConfig 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) |
| Modifier and Type | Method and Description |
|---|---|
<R> R |
bulkCommentedRead(java.util.function.Function<? super UnmodifiableCommentedConfig,R> action)
Performs multiple reads as a single atomic operation, and returns a value.
|
<R> R |
bulkCommentedUpdate(java.util.function.Function<? super CommentedConfig,R> action)
Performs multiple read/write operations, and do not save the configuration until the end
(unless
save() is called by action). |
<R> R |
bulkRead(java.util.function.Function<? super UnmodifiableConfig,R> action)
Performs multiple reads as a single atomic operation and returns a value.
|
<R> R |
bulkUpdate(java.util.function.Function<? super Config,R> action)
Performs multiple reads and writes as a single atomic operation and returns a value.
|
void |
clearComments()
Removes all the comments from the config.
|
void |
close()
Closes this FileConfig, releases its associated resources (if any), and ensure that the
ongoing saving operations complete.
|
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.
|
boolean |
containsComment(java.util.List<java.lang.String> path)
Checks if the config contains a comment at some path.
|
ConcurrentCommentedConfig |
createSubConfig()
Creates a new sub config of this config, as created when a subconfig's creation is
implied by
Config.set(List, Object) or Config.add(List, Object). |
java.util.Set<? extends CommentedConfig.Entry> |
entrySet()
Returns a Set view of the config's entries.
|
java.lang.String |
getComment(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.
|
java.io.File |
getFile() |
java.nio.file.Path |
getNioPath() |
<T> T |
getRaw(java.util.List<java.lang.String> path)
Gets a value from the config.
|
void |
load()
(Re)loads this config from the file.
|
void |
putAllComments(java.util.Map<java.lang.String,UnmodifiableCommentedConfig.CommentNode> comments)
Puts the comments in the given map to this config.
|
void |
putAllComments(UnmodifiableCommentedConfig commentedConfig)
Puts the comments in the given config to this config.
|
java.lang.String |
removeComment(java.util.List<java.lang.String> path)
Removes a comment from the config.
|
void |
save()
Saves this config as soon as possible.
|
<T> T |
set(java.util.List<java.lang.String> path,
java.lang.Object value)
Sets a config value.
|
java.lang.String |
setComment(java.util.List<java.lang.String> path,
java.lang.String comment)
Sets a config comment.
|
java.lang.String |
toString() |
java.util.Map<java.lang.String,java.lang.Object> |
valueMap()
Returns a Map view of the config's values.
|
add, clear, removecontains, equals, hashCode, isEmpty, sizeclone, finalize, getClass, notify, notifyAll, wait, wait, waitbuilder, builder, builder, builder, builder, builder, bulkCommentedUpdate, checked, of, of, of, of, of, of, ofConcurrent, ofConcurrent, ofConcurrent, ofConcurrent, ofConcurrent, ofConcurrentbulkCommentedReadclearComments, commentMap, concurrentCopy, concurrentCopy, concurrentCopy, concurrentCopy, copy, copy, copy, copy, copy, copy, copy, copy, entrySet, fake, inMemory, inMemoryConcurrent, of, of, ofConcurrent, putAllComments, putAllComments, removeComment, removeComment, setComment, setComment, unmodifiable, wrapcontainsComment, containsComment, fake, getComment, getComment, getComments, getComments, getOptionalComment, getOptionalCommentbuilder, builder, builder, bulkUpdate, of, of, of, ofConcurrent, ofConcurrent, ofConcurrentbulkReadadd, add, addAll, clear, getDefaultMapCreator, getDefaultMapCreator, inMemoryUniversal, inMemoryUniversalConcurrent, isInsertionOrderPreserved, of, of, ofConcurrent, putAll, remove, remove, removeAll, set, set, setInsertionOrderPreserved, update, update, valueMapapply, 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, sizepublic ConvertedCommentedFileConfig(CommentedFileConfig config, ConversionTable readTable, ConversionTable writeTable, java.util.function.Predicate<java.lang.Class<?>> supportPredicate)
public ConvertedCommentedFileConfig(CommentedFileConfig 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)
public java.io.File getFile()
getFile in interface FileConfigpublic java.nio.file.Path getNioPath()
getNioPath in interface FileConfigpublic void save()
FileConfigsave in interface FileConfigpublic void load()
FileConfigload in interface FileConfigpublic void close()
FileConfig
A closed FileConfig can still be used via the Config's methods, but FileConfig.save() and
FileConfig.load() will throw an IllegalStateException. Closing an aleady closed FileConfig has
no effect.
close in interface FileConfigclose in interface java.lang.AutoCloseablepublic <R> R bulkRead(java.util.function.Function<? super UnmodifiableConfig,R> action)
ConcurrentConfigIt is guaranteed that the content of the config, accessed through the provided "view", will not change during the entire operation. The configuration must be used exclusively through the object passed to the consumer (the "view"), not with the original reference. After the bulk operation, the view cannot be used anymore.
Here is an example:
String combined = config.bulkUpdate(conf -> {
String a = conf.get("a");
String b = conf.get("b");
return a + b;
// note that we use `conf` and not `config`!
});
bulkRead in interface ConcurrentCommentedConfigbulkRead in interface ConcurrentConfigR - the type of the function's resultaction - a function to execute on the configuration viewpublic <R> R bulkCommentedRead(java.util.function.Function<? super UnmodifiableCommentedConfig,R> action)
ConcurrentCommentedConfigIt is guaranteed that the content of the config, accessed through the provided "view", will not change during the entire operation. The configuration must be used exclusively through the object passed to the consumer (the "view"), not with the original reference. After the bulk operation, the view cannot be used anymore.
Here is an example:
config.bulkCommentedRead(conf -> {
Object value = conf.get("a.b.c");
String comment = conf.getComment("a.b.c");
// note that we use `conf` and not `config`!
});
If you don't need access to the comments, prefer to use ConcurrentCommentedConfig.bulkRead(Function),
sine it may provide a better performance.
bulkCommentedRead in interface ConcurrentCommentedConfigR - the type of the function's resultaction - a function to execute on the configuration viewpublic <R> R bulkCommentedUpdate(java.util.function.Function<? super CommentedConfig,R> action)
CommentedFileConfigsave() is called by action).
This is a way of manually grouping config modifications together.
If this configuration automatically saves, it will not do so before the end of the bulkUpdate.
bulkCommentedUpdate in interface ConcurrentCommentedConfigbulkCommentedUpdate in interface CommentedFileConfigR - the type of the function's resultaction - a function to execute on the configuration viewpublic <R> R bulkUpdate(java.util.function.Function<? super Config,R> action)
ConcurrentConfigIt is guaranteed that the content of the config, accessed through the provided "view", will not be concurrently modified by other threads during the entire bulk operation. The configuration must be used exclusively through the object passed to the consumer (the "view"), not with the original reference. After the bulk operation, the view cannot be used anymore.
Here is an example:
String combined = config.bulkUpdate(conf -> {
String a = conf.get("a");
String b = conf.get("b");
String combined = a + b;
conf.set("combined", combined);
return combined;
// note that we use `conf` and not `config`!
});
If you only have to read the configuration, prefer to use ConcurrentConfig.bulkRead(Function),
since it may provide a better performance.
bulkUpdate in interface ConcurrentCommentedConfigbulkUpdate in interface ConcurrentConfigbulkUpdate in interface CommentedFileConfigbulkUpdate in interface FileConfigR - the type of the function's resultaction - a function to execute on the configuration viewpublic ConcurrentCommentedConfig createSubConfig()
ConfigConfig.set(List, Object) or Config.add(List, Object).createSubConfig in interface CommentedConfigcreateSubConfig in interface ConcurrentCommentedConfigcreateSubConfig in interface ConcurrentConfigcreateSubConfig in interface Configpublic java.lang.String getComment(java.util.List<java.lang.String> path)
UnmodifiableCommentedConfiggetComment in interface UnmodifiableCommentedConfigpath - the comment's path, each element of the list is a different part of the path.null if there is none.public boolean containsComment(java.util.List<java.lang.String> path)
UnmodifiableCommentedConfigcontainsComment in interface UnmodifiableCommentedConfigpath - the path to check, each element of the list is a different part of the path.true if the path is associated with a comment, false if it's not.public java.lang.String setComment(java.util.List<java.lang.String> path,
java.lang.String comment)
CommentedConfigsetComment in interface CommentedConfigpath - the comment's path, each element of the list is a different part of the path.comment - the comment to setnullpublic java.lang.String removeComment(java.util.List<java.lang.String> path)
CommentedConfigremoveComment in interface CommentedConfigpath - the comment's path, each element of the list is a different part of the path.nullpublic void clearComments()
CommentedConfigclearComments in interface CommentedConfigpublic java.util.Map<java.lang.String,UnmodifiableCommentedConfig.CommentNode> getComments()
UnmodifiableCommentedConfiggetComments in interface UnmodifiableCommentedConfigpublic void putAllComments(java.util.Map<java.lang.String,UnmodifiableCommentedConfig.CommentNode> comments)
CommentedConfigputAllComments in interface CommentedConfigcomments - the comments to setpublic void putAllComments(UnmodifiableCommentedConfig commentedConfig)
CommentedConfigThe comments are copied recursively, but missing sub-configurations are NOT created.
putAllComments in interface CommentedConfigcommentedConfig - the config to copy its commentspublic java.util.Map<java.lang.String,java.lang.String> commentMap()
CommentedConfigThe comment map contains only the comments of the direct elements of the configuration, not the comments of their sub-elements.
commentMap in interface CommentedConfigcommentMap in interface UnmodifiableCommentedConfigpublic java.util.Set<? extends CommentedConfig.Entry> entrySet()
UnmodifiableConfigentrySet in interface CommentedConfigentrySet in interface ConfigentrySet in interface UnmodifiableCommentedConfigentrySet in interface UnmodifiableConfigentrySet in class ConfigWrapper<C extends CommentedConfig>public <T> T set(java.util.List<java.lang.String> path,
java.lang.Object value)
Configset in interface Configset in class ConfigWrapper<C extends Config>T - the type of the old valuepath - the value's path, each element of the list is a different part of the path.value - the value to setnullpublic java.util.Map<java.lang.String,java.lang.Object> valueMap()
UnmodifiableConfigvalueMap in interface ConfigvalueMap in interface UnmodifiableConfigvalueMap in class UnmodifiableConfigWrapper<C extends Config>public <T> T getRaw(java.util.List<java.lang.String> path)
UnmodifiableConfigNullObject.NULL_OBJECT to null.getRaw in interface UnmodifiableConfiggetRaw in class UnmodifiableConfigWrapper<C extends Config>T - the value's typepath - the value's path, each element of the list is a different part of the path.null if there is no such value.public ConfigFormat<?> configFormat()
UnmodifiableConfigconfigFormat in interface UnmodifiableConfigconfigFormat in class UnmodifiableConfigWrapper<C extends Config>public java.lang.String toString()
toString in class ConfigWrapper<C extends Config>