Class YamlConfigNode
java.lang.Object
tech.guilhermekaua.spigotboot.config.node.AbstractValueConfigNode
tech.guilhermekaua.spigotboot.config.node.YamlConfigNode
- All Implemented Interfaces:
ConfigNode,MutableConfigNode
YAML-backed implementation of ConfigNode using SnakeYAML.
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a root node.YamlConfigNode(@Nullable Object data) Creates a node from existing data. -
Method Summary
Modifier and TypeMethodDescription@NotNull MutableConfigNodeAppends a new item to this list node.protected @NotNull ConfigNodecreateChildNode(@Nullable Object value, @NotNull PropertyPath path, boolean virtual) protected @NotNull PropertyPathprotected @Nullable Objectprotected booleanGets all child comments.getChildComments(@NotNull String key) Gets comments for a specific child key.Gets the comments for this node.booleanChecks if this node has a child at the given path.@NotNull MutableConfigNodeNavigates to a child node by path segments.@NotNull ConfigNodenode(@NotNull PropertyPath path) Navigates to a child node by a property path.@NotNull MutableConfigNoderemove()Removes this node from its parent.@NotNull MutableConfigNodeSets the value of this node.@NotNull MutableConfigNodesetComment(@Nullable String... lines) Sets a comment for this node (if supported by the format).Methods inherited from class tech.guilhermekaua.spigotboot.config.node.AbstractValueConfigNode
childrenList, childrenMap, get, get, isList, isMap, isNull, isScalar, isVirtual, path, rawMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface tech.guilhermekaua.spigotboot.config.node.ConfigNode
childrenList, childrenMap, get, get, isList, isMap, isNull, isScalar, isVirtual, path, raw
-
Constructor Details
-
YamlConfigNode
public YamlConfigNode()Creates a root node. -
YamlConfigNode
Creates a node from existing data.- Parameters:
data- the raw data
-
-
Method Details
-
currentValue
- Specified by:
currentValuein classAbstractValueConfigNode
-
currentPath
- Specified by:
currentPathin classAbstractValueConfigNode
-
currentVirtual
protected boolean currentVirtual()- Specified by:
currentVirtualin classAbstractValueConfigNode
-
createChildNode
@NotNull protected @NotNull ConfigNode createChildNode(@Nullable @Nullable Object value, @NotNull @NotNull PropertyPath path, boolean virtual) - Specified by:
createChildNodein classAbstractValueConfigNode
-
node
Description copied from interface:ConfigNodeNavigates to a child node by path segments.If the path doesn't exist, returns a virtual (empty) node.
- Specified by:
nodein interfaceConfigNode- Specified by:
nodein interfaceMutableConfigNode- Overrides:
nodein classAbstractValueConfigNode- Parameters:
pathSegments- the path segments (strings for map keys, integers for list indices)- Returns:
- the child node, never null
-
node
Description copied from interface:ConfigNodeNavigates to a child node by a property path.If the path doesn't exist, returns a virtual (empty) node.
- Specified by:
nodein interfaceConfigNode- Specified by:
nodein interfaceMutableConfigNode- Overrides:
nodein classAbstractValueConfigNode- Parameters:
path- thePropertyPathto navigate to- Returns:
- the child node, never null
-
hasChild
Description copied from interface:ConfigNodeChecks if this node has a child at the given path.- Specified by:
hasChildin interfaceConfigNode- Overrides:
hasChildin classAbstractValueConfigNode- Parameters:
pathSegments- the path segments- Returns:
- true if the child exists and is not virtual
-
set
Description copied from interface:MutableConfigNodeSets the value of this node.- Specified by:
setin interfaceMutableConfigNode- Parameters:
newValue- the value to set, or null to clear- Returns:
- this node for chaining
-
setComment
Description copied from interface:MutableConfigNodeSets a comment for this node (if supported by the format).- Specified by:
setCommentin interfaceMutableConfigNode- Parameters:
lines- the comment lines, or null to remove- Returns:
- this node for chaining
-
getComments
Gets the comments for this node.- Returns:
- the comments, or null
-
getChildComments
Gets comments for a specific child key.- Parameters:
key- the child key- Returns:
- the comments, or null
-
getAllChildComments
Gets all child comments.- Returns:
- map of key to comment lines
-
remove
Description copied from interface:MutableConfigNodeRemoves this node from its parent.- Specified by:
removein interfaceMutableConfigNode- Returns:
- this node for chaining
-
appendListItem
Description copied from interface:MutableConfigNodeAppends a new item to this list node.If this node is not a list, it will be converted to one.
- Specified by:
appendListItemin interfaceMutableConfigNode- Returns:
- the new list item node
-