Interface AttributedConfigurationNode
-
- All Superinterfaces:
CommentedConfigurationNode
,ConfigurationNode
- All Known Implementing Classes:
SimpleAttributedConfigurationNode
public interface AttributedConfigurationNode extends CommentedConfigurationNode
A configuration node that can have both comments and attributes attached to it.
-
-
Field Summary
-
Fields inherited from interface ninja.leaping.configurate.ConfigurationNode
NUMBER_DEF
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description default AttributedConfigurationNode
act(Consumer<? super ConfigurationNode> action)
Execute an action on this node.@NonNull AttributedConfigurationNode
addAttribute(@NonNull String name, @NonNull String value)
Adds an attribute to this node.default @NonNull AttributedConfigurationNode
appendListNode()
Gets a new child node created as the next entry in the list.@NonNull AttributedConfigurationNode
copy()
Creates a deep copy of this node.@NonNull AttributedConfigurationNode
getAppendedNode()
Deprecated.@Nullable String
getAttribute(@NonNull String name)
Gets the value of an attribute, or null if this node doesn't have the given attribute.@NonNull Map<String,String>
getAttributes()
Gets the attributes this node has.@NonNull List<? extends AttributedConfigurationNode>
getChildrenList()
Gets the "list children" attached to this node, if it has any.@NonNull Map<Object,? extends AttributedConfigurationNode>
getChildrenMap()
Gets the "map children" attached to this node, if it has any.default @NonNull Optional<String>
getComment()
Gets the current value for the comment.@NonNull AttributedConfigurationNode
getNode(@NonNull Object... path)
Gets the node at the given (relative) path, possibly traversing multiple levels of nodes.@Nullable AttributedConfigurationNode
getParent()
Gets the parent of this node.@NonNull String
getTagName()
Gets the tag name of this node.boolean
hasAttributes()
Gets if this node has any attributes.@NonNull AttributedConfigurationNode
mergeValuesFrom(@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.@NonNull AttributedConfigurationNode
removeAttribute(@NonNull String name)
Removes an attribute from this node.static @NonNull AttributedConfigurationNode
root()
Create a new node with no parent and the tag nameroot
static @NonNull AttributedConfigurationNode
root(@NonNull String tagName)
Create a new node with no parent and a specified tag name.static @NonNull AttributedConfigurationNode
root(@NonNull String tagName, @NonNull ConfigurationOptions options)
Create a new node with no parent, a specified tag name, and specific options.static @NonNull AttributedConfigurationNode
root(@NonNull String tagName, @NonNull ConfigurationOptions options, Consumer<? super AttributedConfigurationNode> action)
Create a new node with no parent, a specified tag name, and specific options, and perform an action with it in scopestatic @NonNull AttributedConfigurationNode
root(@NonNull String tagName, Consumer<? super AttributedConfigurationNode> action)
Create a new node with no parent and a specified tag name, and perform an action with it in scopestatic AttributedConfigurationNode
root(Consumer<? super AttributedConfigurationNode> action)
Create a new node with no parent and the tag nameroot
, and perform an action with it in scope@NonNull AttributedConfigurationNode
setAttributes(@NonNull Map<String,String> attributes)
Sets the attributes of this node.default @NonNull AttributedConfigurationNode
setComment(@Nullable String value)
Sets the comment for this configuration node.@NonNull AttributedConfigurationNode
setTagName(@NonNull String name)
Sets the tag name of this node.@NonNull AttributedConfigurationNode
setValue(@Nullable Object value)
Set this node's value to the given value.-
Methods inherited from interface ninja.leaping.configurate.commented.CommentedConfigurationNode
setCommentIfAbsent
-
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 Detail
-
root
static @NonNull AttributedConfigurationNode root()
Create a new node with no parent and the tag nameroot
- Returns:
- a new node
-
root
static AttributedConfigurationNode root(Consumer<? super AttributedConfigurationNode> action)
Create a new node with no parent and the tag nameroot
, and perform an action with it in scope- Parameters:
action
- action to perform to initialize the created node- Returns:
- a new node
-
root
static @NonNull AttributedConfigurationNode root(@NonNull String tagName)
Create a new node with no parent and a specified tag name.- Parameters:
tagName
- The name of the tag to be used to represent this node- Returns:
- a new node
-
root
static @NonNull AttributedConfigurationNode root(@NonNull String tagName, Consumer<? super AttributedConfigurationNode> action)
Create a new node with no parent and a specified tag name, and perform an action with it in scope- Parameters:
tagName
- The name of the tag to be used to represent this nodeaction
- action to perform to initialize the created node- Returns:
- a new node
-
root
static @NonNull AttributedConfigurationNode root(@NonNull String tagName, @NonNull ConfigurationOptions options)
Create a new node with no parent, a specified tag name, and specific options.- Parameters:
tagName
- The name of the tag to be used to represent this nodeoptions
- The options to use within this node- Returns:
- a new node
-
root
static @NonNull AttributedConfigurationNode root(@NonNull String tagName, @NonNull ConfigurationOptions options, Consumer<? super AttributedConfigurationNode> action)
Create a new node with no parent, a specified tag name, and specific options, and perform an action with it in scope- Parameters:
tagName
- The name of the tag to be used to represent this nodeoptions
- The options to use within this nodeaction
- action to perform to initialize the created node- Returns:
- a new node
-
getTagName
@NonNull String getTagName()
Gets the tag name of this node.- Returns:
- The tag name
-
setTagName
@NonNull AttributedConfigurationNode setTagName(@NonNull String name)
Sets the tag name of this node.Will have no effect when called on nodes which are direct values of a
child map
, as the corresponding key is used as the tag name.- Parameters:
name
- The name to set, cannot be null- Returns:
- this
-
addAttribute
@NonNull AttributedConfigurationNode addAttribute(@NonNull String name, @NonNull String value)
Adds an attribute to this node.- Parameters:
name
- The name of the attributevalue
- The value of the attribute- Returns:
- this
-
removeAttribute
@NonNull AttributedConfigurationNode removeAttribute(@NonNull String name)
Removes an attribute from this node.- Parameters:
name
- The name of the attribute to remove- Returns:
- this
-
setAttributes
@NonNull AttributedConfigurationNode setAttributes(@NonNull Map<String,String> attributes)
Sets the attributes of this node.- Parameters:
attributes
- the attributes to set- Returns:
- this
-
hasAttributes
boolean hasAttributes()
Gets if this node has any attributes.- Returns:
- true if this node has any attributes
-
getAttribute
@Nullable String getAttribute(@NonNull String name)
Gets the value of an attribute, or null if this node doesn't have the given attribute.- Parameters:
name
- The name of the attribute to get- Returns:
- this
-
getAttributes
@NonNull Map<String,String> getAttributes()
Gets the attributes this node has.The returned map is immutable.
- Returns:
- The map of attributes
-
getComment
default @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
-
getParent
@Nullable AttributedConfigurationNode 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
- Returns:
- The nodes parent
-
getChildrenList
@NonNull List<? extends AttributedConfigurationNode> 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
- Returns:
- The list children currently attached to this node
-
getChildrenMap
@NonNull Map<Object,? extends AttributedConfigurationNode> 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
- Returns:
- The map children currently attached to this node
-
setComment
default @NonNull AttributedConfigurationNode setComment(@Nullable String value)
Description copied from interface:CommentedConfigurationNode
Sets the comment for this configuration node.- Specified by:
setComment
in interfaceCommentedConfigurationNode
- Parameters:
value
- The comment to set. Line breaks should be represented as LFs (\n)- Returns:
- this
-
setValue
@NonNull AttributedConfigurationNode 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
- Parameters:
value
- The value to set- Returns:
- this
- See Also:
to set a value with any type conversion necessary
-
mergeValuesFrom
@NonNull AttributedConfigurationNode 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
- Parameters:
other
- The node to merge values from- Returns:
- this
-
getAppendedNode
@Deprecated @NonNull AttributedConfigurationNode 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
- Returns:
- A new child created as the next entry in the list when it is attached
-
appendListNode
default @NonNull AttributedConfigurationNode 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
-
getNode
@NonNull AttributedConfigurationNode 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
- Parameters:
path
- The path to fetch the node at- Returns:
- The node at the given path, possibly virtual
-
copy
@NonNull AttributedConfigurationNode 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
- Returns:
- A copy of this node
-
act
default AttributedConfigurationNode act(Consumer<? super ConfigurationNode> action)
Description copied from interface:ConfigurationNode
Execute an action on this node. This allows performing multiple operations on a single node without having to clutter up the surrounding scope.- Specified by:
act
in interfaceCommentedConfigurationNode
- Specified by:
act
in interfaceConfigurationNode
- Parameters:
action
- The action to perform on this node- Returns:
- this
-
-