Class SimpleAttributedConfigurationNode
- All Implemented Interfaces:
AttributedConfigurationNode
,CommentedConfigurationNode
,ConfigurationNode
public class SimpleAttributedConfigurationNode extends SimpleCommentedConfigurationNode implements AttributedConfigurationNode
AttributedConfigurationNode
.-
Field Summary
Fields inherited from interface ninja.leaping.configurate.ConfigurationNode
NUMBER_DEF
-
Constructor Summary
Constructors Modifier Constructor Description protected
SimpleAttributedConfigurationNode(@NonNull String tagName, @Nullable Object path, @Nullable SimpleConfigurationNode parent, @NonNull ConfigurationOptions options)
protected
SimpleAttributedConfigurationNode(@NonNull String tagName, @Nullable SimpleConfigurationNode parent, @NonNull SimpleConfigurationNode copyOf)
-
Method Summary
Methods inherited from class ninja.leaping.configurate.commented.SimpleCommentedConfigurationNode
getComment, root, setCommentIfAbsent
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, 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.attributed.AttributedConfigurationNode
act, getComment
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, isList, isMap, isVirtual, removeChild, setValue, visit, visit, visit, visit
-
Constructor Details
-
SimpleAttributedConfigurationNode
protected SimpleAttributedConfigurationNode(@NonNull String tagName, @Nullable Object path, @Nullable SimpleConfigurationNode parent, @NonNull ConfigurationOptions options) -
SimpleAttributedConfigurationNode
protected SimpleAttributedConfigurationNode(@NonNull String tagName, @Nullable SimpleConfigurationNode parent, @NonNull SimpleConfigurationNode copyOf)
-
-
Method Details
-
root
Deprecated.UseAttributedConfigurationNode.root()
insteadCreate a new node with no parent.- Returns:
- a new node
-
root
Deprecated.UseAttributedConfigurationNode.root(String)
insteadCreate a new node with no parent.- Parameters:
tagName
- The name of the tag to be used to represent this node- Returns:
- a new node
-
root
@Deprecated public static @NonNull SimpleAttributedConfigurationNode root(@NonNull String tagName, @NonNull ConfigurationOptions options)Deprecated.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
-
getTagName
Description copied from interface:AttributedConfigurationNode
Gets the tag name of this node.- Specified by:
getTagName
in interfaceAttributedConfigurationNode
- Returns:
- The tag name
-
setTagName
Description copied from interface:AttributedConfigurationNode
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.- Specified by:
setTagName
in interfaceAttributedConfigurationNode
- Parameters:
tagName
- The name to set, cannot be null- Returns:
- this
-
addAttribute
public @NonNull SimpleAttributedConfigurationNode addAttribute(@NonNull String name, @NonNull String value)Description copied from interface:AttributedConfigurationNode
Adds an attribute to this node.- Specified by:
addAttribute
in interfaceAttributedConfigurationNode
- Parameters:
name
- The name of the attributevalue
- The value of the attribute- Returns:
- this
-
removeAttribute
Description copied from interface:AttributedConfigurationNode
Removes an attribute from this node.- Specified by:
removeAttribute
in interfaceAttributedConfigurationNode
- Parameters:
name
- The name of the attribute to remove- Returns:
- this
-
setAttributes
public @NonNull SimpleAttributedConfigurationNode setAttributes(@NonNull Map<String,String> attributes)Description copied from interface:AttributedConfigurationNode
Sets the attributes of this node.- Specified by:
setAttributes
in interfaceAttributedConfigurationNode
- Parameters:
attributes
- the attributes to set- Returns:
- this
-
hasAttributes
Description copied from interface:AttributedConfigurationNode
Gets if this node has any attributes.- Specified by:
hasAttributes
in interfaceAttributedConfigurationNode
- Returns:
- true if this node has any attributes
-
getAttribute
Description copied from interface:AttributedConfigurationNode
Gets the value of an attribute, or null if this node doesn't have the given attribute.- Specified by:
getAttribute
in interfaceAttributedConfigurationNode
- Parameters:
name
- The name of the attribute to get- Returns:
- this
-
getAttributes
Description copied from interface:AttributedConfigurationNode
Gets the attributes this node has.The returned map is immutable.
- Specified by:
getAttributes
in interfaceAttributedConfigurationNode
- Returns:
- The map of attributes
-
isEmpty
Description copied from interface:ConfigurationNode
Return true when this node has a null or empty value. Values that may result in this method returning true include:null
- the empty string
- an empty map
- an empty list
- Any other type of empty collection
ConfigurationNode.isVirtual()
. Emptiness refers to the value of this node itself, while virtuality refers to whether or not this node is attached to its parent and the rest of the configuration structure.- Specified by:
isEmpty
in interfaceConfigurationNode
- Overrides:
isEmpty
in classSimpleConfigurationNode
- Returns:
- Whether this node is empty
-
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 interfaceAttributedConfigurationNode
- Specified by:
getParent
in interfaceCommentedConfigurationNode
- Specified by:
getParent
in interfaceConfigurationNode
- Overrides:
getParent
in classSimpleCommentedConfigurationNode
- Returns:
- The nodes parent
-
createNode
- Overrides:
createNode
in classSimpleCommentedConfigurationNode
-
setValue
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 interfaceAttributedConfigurationNode
- Specified by:
setValue
in interfaceCommentedConfigurationNode
- Specified by:
setValue
in interfaceConfigurationNode
- Overrides:
setValue
in classSimpleCommentedConfigurationNode
- Parameters:
value
- The value to set- Returns:
- this
- See Also:
to set a value with any type conversion necessary
-
mergeValuesFrom
public @NonNull SimpleAttributedConfigurationNode 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 interfaceAttributedConfigurationNode
- Specified by:
mergeValuesFrom
in interfaceCommentedConfigurationNode
- Specified by:
mergeValuesFrom
in interfaceConfigurationNode
- Overrides:
mergeValuesFrom
in classSimpleCommentedConfigurationNode
- Parameters:
other
- The node to merge values from- Returns:
- this
-
getNode
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 interfaceAttributedConfigurationNode
- Specified by:
getNode
in interfaceCommentedConfigurationNode
- Specified by:
getNode
in interfaceConfigurationNode
- Overrides:
getNode
in classSimpleCommentedConfigurationNode
- Parameters:
path
- The path to fetch the node at- Returns:
- The node at the given path, possibly virtual
-
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 interfaceAttributedConfigurationNode
- Specified by:
getChildrenList
in interfaceCommentedConfigurationNode
- Specified by:
getChildrenList
in interfaceConfigurationNode
- Overrides:
getChildrenList
in classSimpleCommentedConfigurationNode
- Returns:
- The list children currently attached to this node
-
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 interfaceAttributedConfigurationNode
- Specified by:
getChildrenMap
in interfaceCommentedConfigurationNode
- Specified by:
getChildrenMap
in interfaceConfigurationNode
- Overrides:
getChildrenMap
in classSimpleCommentedConfigurationNode
- Returns:
- The map children currently attached to this node
-
getAppendedNode
Deprecated.Description copied from interface:ConfigurationNode
Gets a new child node created as the next entry in the list.- Specified by:
getAppendedNode
in interfaceAttributedConfigurationNode
- Specified by:
getAppendedNode
in interfaceCommentedConfigurationNode
- Specified by:
getAppendedNode
in interfaceConfigurationNode
- Overrides:
getAppendedNode
in classSimpleCommentedConfigurationNode
- Returns:
- A new child created as the next entry in the list when it is attached
-
appendListNode
Description copied from interface:ConfigurationNode
Gets a new child node created as the next entry in the list.- Specified by:
appendListNode
in interfaceAttributedConfigurationNode
- Specified by:
appendListNode
in interfaceCommentedConfigurationNode
- Specified by:
appendListNode
in interfaceConfigurationNode
- Overrides:
appendListNode
in classSimpleCommentedConfigurationNode
- Returns:
- A new child created as the next entry in the list when it is attached
-
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 interfaceAttributedConfigurationNode
- Specified by:
copy
in interfaceCommentedConfigurationNode
- Specified by:
copy
in interfaceConfigurationNode
- Overrides:
copy
in classSimpleCommentedConfigurationNode
- Returns:
- A copy of this node
-
copy
protected @NonNull SimpleAttributedConfigurationNode copy(@Nullable SimpleConfigurationNode parent)- Overrides:
copy
in classSimpleCommentedConfigurationNode
-
setComment
Description copied from interface:CommentedConfigurationNode
Sets the comment for this configuration node.- Specified by:
setComment
in interfaceAttributedConfigurationNode
- Specified by:
setComment
in interfaceCommentedConfigurationNode
- Overrides:
setComment
in classSimpleCommentedConfigurationNode
- Parameters:
comment
- The comment to set. Line breaks should be represented as LFs (\n)- Returns:
- this
-
equals
- Overrides:
equals
in classSimpleCommentedConfigurationNode
-
hashCode
- Overrides:
hashCode
in classSimpleCommentedConfigurationNode
-
toString
- Overrides:
toString
in classSimpleCommentedConfigurationNode
-
AttributedConfigurationNode.root()
instead