Interface CommentedConfigurationNode
- All Superinterfaces:
ConfigurationNode
- All Known Subinterfaces:
AttributedConfigurationNode
- All Known Implementing Classes:
SimpleAttributedConfigurationNode,SimpleCommentedConfigurationNode
public interface CommentedConfigurationNode extends ConfigurationNode
-
Field Summary
-
Method Summary
Modifier and Type Method Description default CommentedConfigurationNodeact(Consumer<? super ConfigurationNode> action)Execute an action on this node.default @NonNull CommentedConfigurationNodeappendListNode()Gets a new child node created as the next entry in the list.@NonNull CommentedConfigurationNodecopy()Creates a deep copy of this node.@NonNull CommentedConfigurationNodegetAppendedNode()Deprecated.@NonNull List<? extends CommentedConfigurationNode>getChildrenList()Gets the "list children" attached to this node, if it has any.@NonNull Map<Object,? extends CommentedConfigurationNode>getChildrenMap()Gets the "map children" attached to this node, if it has any.@NonNull Optional<String>getComment()Gets the current value for the comment.@NonNull CommentedConfigurationNodegetNode(@NonNull Object... path)Gets the node at the given (relative) path, possibly traversing multiple levels of nodes.@Nullable CommentedConfigurationNodegetParent()Gets the parent of this node.@NonNull CommentedConfigurationNodemergeValuesFrom(@NonNull ConfigurationNode other)Set all the values from the given node that are not present in this node to their values in the provided node.static @NonNull CommentedConfigurationNoderoot()static @NonNull CommentedConfigurationNoderoot(@NonNull Consumer<? super CommentedConfigurationNode> action)static @NonNull CommentedConfigurationNoderoot(@NonNull ConfigurationOptions options)static @NonNull CommentedConfigurationNoderoot(@NonNull ConfigurationOptions options, @NonNull Consumer<? super CommentedConfigurationNode> action)@NonNull CommentedConfigurationNodesetComment(@Nullable String comment)Sets the comment for this configuration node.default @NonNull CommentedConfigurationNodesetCommentIfAbsent(String comment)Set a comment on this node if it does not presently have a comment.@NonNull CommentedConfigurationNodesetValue(@Nullable Object value)Set this node's value to the given value.Methods inherited from interface ninja.leaping.configurate.ConfigurationNode
getBoolean, getBoolean, getDouble, getDouble, getFloat, getFloat, getInt, getInt, getKey, getList, getList, getList, getList, getList, getList, getLong, getLong, getNode, getOptions, getPath, getString, getString, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValueType, hasListChildren, hasMapChildren, isEmpty, isList, isMap, isVirtual, removeChild, setValue, visit, visit, visit, visit
-
Method Details
-
root
-
root
static @NonNull CommentedConfigurationNode root(@NonNull Consumer<? super CommentedConfigurationNode> action) -
root
-
root
static @NonNull CommentedConfigurationNode root(@NonNull ConfigurationOptions options, @NonNull Consumer<? super CommentedConfigurationNode> action) -
getComment
Gets the current value for the comment.If the comment contains multiple lines, the lines will be split by \n
- Returns:
- The configuration's current comment
-
setComment
Sets the comment for this configuration node.- Parameters:
comment- The comment to set. Line breaks should be represented as LFs (\n)- Returns:
- this
-
setCommentIfAbsent
Set a comment on this node if it does not presently have a comment. The provided comment must not be null, because setting a null comment would be a no-op- Parameters:
comment- The comment to set. Line breaks should be represented as LFs (\n)- Returns:
- this
-
getParent
Description copied from interface:ConfigurationNodeGets the parent of this node.If this node is currently
virtual, this method's result may be inaccurate.- Specified by:
getParentin interfaceConfigurationNode- Returns:
- The nodes parent
-
getChildrenList
@NonNull List<? extends CommentedConfigurationNode> getChildrenList()Description copied from interface:ConfigurationNodeGets the "list children" attached to this node, if it has any.If this node does not
have list children, an empty list is returned. For example, if the value of this node is a map, this will return an empty result.- Specified by:
getChildrenListin interfaceConfigurationNode- Returns:
- The list children currently attached to this node
-
getChildrenMap
@NonNull Map<Object,? extends CommentedConfigurationNode> getChildrenMap()Description copied from interface:ConfigurationNodeGets the "map children" attached to this node, if it has any.If this node does not
have map children, an empty map returned.- Specified by:
getChildrenMapin interfaceConfigurationNode- Returns:
- The map children currently attached to this node
-
setValue
Description copied from interface:ConfigurationNodeSet this node's value to the given value.If the provided value is a
This method only accepts native types as values. If the type of a value is unknown at runtime,Collectionor aMap, it will be unwrapped into the appropriate configuration node structure.ConfigurationOptions.acceptsType(Class)will return whether or not it is a native type.- Specified by:
setValuein interfaceConfigurationNode- Parameters:
value- The value to set- Returns:
- this
- See Also:
to set a value with any type conversion necessary
-
mergeValuesFrom
Description copied from interface:ConfigurationNodeSet all the values from the given node that are not present in this node to their values in the provided node.Map keys will be merged. Lists and scalar values will be replaced.
- Specified by:
mergeValuesFromin interfaceConfigurationNode- Parameters:
other- The node to merge values from- Returns:
- this
-
getAppendedNode
Deprecated.Description copied from interface:ConfigurationNodeGets a new child node created as the next entry in the list.- Specified by:
getAppendedNodein interfaceConfigurationNode- Returns:
- A new child created as the next entry in the list when it is attached
-
appendListNode
Description copied from interface:ConfigurationNodeGets a new child node created as the next entry in the list.- Specified by:
appendListNodein interfaceConfigurationNode- Returns:
- A new child created as the next entry in the list when it is attached
-
getNode
Description copied from interface:ConfigurationNodeGets the node at the given (relative) path, possibly traversing multiple levels of nodes.This is the main method used to navigate through the configuration.
The path parameter effectively consumes an array of keys, which locate the unique position of a given node within the structure. Each element will navigate one level down in the configration hierarchy
A node is always returned by this method. If the given node does not exist in the structure, a
virtualnode will be returned which represents the position.- Specified by:
getNodein interfaceConfigurationNode- Parameters:
path- The path to fetch the node at- Returns:
- The node at the given path, possibly virtual
-
copy
Description copied from interface:ConfigurationNodeCreates a deep copy of this node.If this node has child nodes (is a list or map), the child nodes will also be copied. This action is performed recursively.
The resultant node will (initially) contain the same value(s) as this node, and will therefore be
equal, however, changes made to the original will not be reflected in the copy, and vice versa.The actual scalar values that back the configuration will not be copied - only the node structure that forms the configuration. This is not a problem in most cases, as the scalar values stored in configurations are usually immutable. (e.g. strings, numbers, booleans).
- Specified by:
copyin interfaceConfigurationNode- Returns:
- A copy of this node
-
act
Description copied from interface:ConfigurationNodeExecute an action on this node. This allows performing multiple operations on a single node without having to clutter up the surrounding scope.- Specified by:
actin interfaceConfigurationNode- Parameters:
action- The action to perform on this node- Returns:
- this
-