Class SimpleCommentedConfigurationNode
- java.lang.Object
-
- ninja.leaping.configurate.SimpleConfigurationNode
-
- ninja.leaping.configurate.commented.SimpleCommentedConfigurationNode
-
- All Implemented Interfaces:
CommentedConfigurationNode
,ConfigurationNode
- Direct Known Subclasses:
SimpleAttributedConfigurationNode
public class SimpleCommentedConfigurationNode extends SimpleConfigurationNode implements CommentedConfigurationNode
Basic implementation ofCommentedConfigurationNode
.
-
-
Field Summary
-
Fields inherited from interface ninja.leaping.configurate.ConfigurationNode
NUMBER_DEF
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
SimpleCommentedConfigurationNode(@Nullable Object path, @Nullable SimpleConfigurationNode parent, @NonNull ConfigurationOptions options)
protected
SimpleCommentedConfigurationNode(@Nullable SimpleConfigurationNode parent, @NonNull SimpleConfigurationNode copyOf)
-
Method Summary
-
Methods inherited from class ninja.leaping.configurate.SimpleConfigurationNode
attachChildIfAbsent, attachIfNecessary, clear, getChild, getKey, getList, getList, getList, getList, getList, getNode, getOptions, getPath, getValue, getValue, getValue, getValue, getValue, getValue, getValueType, isEmpty, isVirtual, removeChild, visit, visit
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface ninja.leaping.configurate.commented.CommentedConfigurationNode
act
-
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
-
-
-
-
Constructor Detail
-
SimpleCommentedConfigurationNode
protected SimpleCommentedConfigurationNode(@Nullable Object path, @Nullable SimpleConfigurationNode parent, @NonNull ConfigurationOptions options)
-
SimpleCommentedConfigurationNode
protected SimpleCommentedConfigurationNode(@Nullable SimpleConfigurationNode parent, @NonNull SimpleConfigurationNode copyOf)
-
-
Method Detail
-
root
@Deprecated public static @NonNull SimpleCommentedConfigurationNode root()
Deprecated.UseCommentedConfigurationNode.root()
insteadCreate a new node with no parent.- Returns:
- The newly created node
-
root
@Deprecated public static @NonNull SimpleCommentedConfigurationNode root(@NonNull ConfigurationOptions options)
Deprecated.Create a new node with no parent and defined options- Parameters:
options
- The options to use in this node.- Returns:
- The newly created node
-
getComment
public @NonNull Optional<String> getComment()
Description copied from interface:CommentedConfigurationNode
Gets the current value for the comment.If the comment contains multiple lines, the lines will be split by \n
- Specified by:
getComment
in interfaceCommentedConfigurationNode
- Returns:
- The configuration's current comment
-
setComment
public @NonNull SimpleCommentedConfigurationNode setComment(@Nullable String comment)
Description copied from interface:CommentedConfigurationNode
Sets the comment for this configuration node.- Specified by:
setComment
in interfaceCommentedConfigurationNode
- Parameters:
comment
- The comment to set. Line breaks should be represented as LFs (\n)- Returns:
- this
-
setCommentIfAbsent
public @NonNull CommentedConfigurationNode setCommentIfAbsent(String comment)
Description copied from interface:CommentedConfigurationNode
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- Specified by:
setCommentIfAbsent
in interfaceCommentedConfigurationNode
- Parameters:
comment
- The comment to set. Line breaks should be represented as LFs (\n)- Returns:
- this
-
getParent
public @Nullable SimpleCommentedConfigurationNode getParent()
Description copied from interface:ConfigurationNode
Gets the parent of this node.If this node is currently
virtual
, this method's result may be inaccurate.- Specified by:
getParent
in interfaceCommentedConfigurationNode
- Specified by:
getParent
in interfaceConfigurationNode
- Overrides:
getParent
in classSimpleConfigurationNode
- Returns:
- The nodes parent
-
createNode
protected SimpleCommentedConfigurationNode createNode(Object path)
- Overrides:
createNode
in classSimpleConfigurationNode
-
setValue
public @NonNull SimpleCommentedConfigurationNode setValue(@Nullable Object value)
Description copied from interface:ConfigurationNode
Set 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,Collection
or 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:
setValue
in interfaceCommentedConfigurationNode
- Specified by:
setValue
in interfaceConfigurationNode
- Overrides:
setValue
in classSimpleConfigurationNode
- Parameters:
value
- The value to set- Returns:
- this
- See Also:
to set a value with any type conversion necessary
-
mergeValuesFrom
public @NonNull SimpleCommentedConfigurationNode mergeValuesFrom(@NonNull ConfigurationNode other)
Description copied from interface:ConfigurationNode
Set 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:
mergeValuesFrom
in interfaceCommentedConfigurationNode
- Specified by:
mergeValuesFrom
in interfaceConfigurationNode
- Overrides:
mergeValuesFrom
in classSimpleConfigurationNode
- Parameters:
other
- The node to merge values from- Returns:
- this
-
getNode
public @NonNull SimpleCommentedConfigurationNode getNode(@NonNull Object... path)
Description copied from interface:ConfigurationNode
Gets 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
virtual
node will be returned which represents the position.- Specified by:
getNode
in interfaceCommentedConfigurationNode
- Specified by:
getNode
in interfaceConfigurationNode
- Overrides:
getNode
in classSimpleConfigurationNode
- Parameters:
path
- The path to fetch the node at- Returns:
- The node at the given path, possibly virtual
-
getChildrenList
public @NonNull List<? extends SimpleCommentedConfigurationNode> getChildrenList()
Description copied from interface:ConfigurationNode
Gets 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:
getChildrenList
in interfaceCommentedConfigurationNode
- Specified by:
getChildrenList
in interfaceConfigurationNode
- Overrides:
getChildrenList
in classSimpleConfigurationNode
- Returns:
- The list children currently attached to this node
-
getChildrenMap
public @NonNull Map<Object,? extends SimpleCommentedConfigurationNode> getChildrenMap()
Description copied from interface:ConfigurationNode
Gets 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:
getChildrenMap
in interfaceCommentedConfigurationNode
- Specified by:
getChildrenMap
in interfaceConfigurationNode
- Overrides:
getChildrenMap
in classSimpleConfigurationNode
- Returns:
- The map children currently attached to this node
-
getAppendedNode
@Deprecated public @NonNull SimpleCommentedConfigurationNode getAppendedNode()
Deprecated.Description copied from interface:ConfigurationNode
Gets a new child node created as the next entry in the list.- Specified by:
getAppendedNode
in interfaceCommentedConfigurationNode
- Specified by:
getAppendedNode
in interfaceConfigurationNode
- Overrides:
getAppendedNode
in classSimpleConfigurationNode
- Returns:
- A new child created as the next entry in the list when it is attached
-
appendListNode
public @NonNull SimpleCommentedConfigurationNode appendListNode()
Description copied from interface:ConfigurationNode
Gets a new child node created as the next entry in the list.- Specified by:
appendListNode
in interfaceCommentedConfigurationNode
- Specified by:
appendListNode
in interfaceConfigurationNode
- Returns:
- A new child created as the next entry in the list when it is attached
-
copy
public @NonNull SimpleCommentedConfigurationNode copy()
Description copied from interface:ConfigurationNode
Creates 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:
copy
in interfaceCommentedConfigurationNode
- Specified by:
copy
in interfaceConfigurationNode
- Overrides:
copy
in classSimpleConfigurationNode
- Returns:
- A copy of this node
-
copy
protected @NonNull SimpleCommentedConfigurationNode copy(@Nullable SimpleConfigurationNode parent)
- Overrides:
copy
in classSimpleConfigurationNode
-
equals
public boolean equals(Object o)
- Overrides:
equals
in classSimpleConfigurationNode
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classSimpleConfigurationNode
-
toString
public String toString()
- Overrides:
toString
in classSimpleConfigurationNode
-
-