Interface ConfigNode
- All Known Subinterfaces:
MutableConfigNode
- All Known Implementing Classes:
AbstractValueConfigNode,SnapshotConfigNode,YamlConfigNode
public interface ConfigNode
Immutable representation of a configuration node.
A ConfigNode wraps a value in the configuration tree and provides type-safe access to its data. Nodes can be scalars, maps, or lists.
-
Method Summary
Modifier and TypeMethodDescription@NotNull List<? extends ConfigNode>Gets all children as a list (for list nodes).@NotNull Map<String,? extends ConfigNode> Gets all children as a map (for map nodes).<T> TGets the value converted to the specified type.<T> TGets the value converted to the specified type, with a default fallback.booleanChecks if this node has a child at the given path.booleanisList()Checks if this node is a list (array) node.booleanisMap()Checks if this node is a map (object) node.booleanisNull()Checks if this node's value is null.booleanisScalar()Checks if this node is a scalar (primitive/string) value.booleanChecks if this node is virtual (doesn't exist in the source).@NotNull ConfigNodeNavigates to a child node by path segments.@NotNull ConfigNodenode(@NotNull PropertyPath path) Navigates to a child node by a property path.@NotNull PropertyPathpath()Gets the path to this node from root.@Nullable Objectraw()Gets the raw underlying value.
-
Method Details
-
raw
Gets the raw underlying value.- Returns:
- the raw value, or null if the node is empty
-
get
Gets the value converted to the specified type.- Type Parameters:
T- the type parameter- Parameters:
type- the target type- Returns:
- the converted value, or null if conversion fails or value is null
-
get
Gets the value converted to the specified type, with a default fallback.- Type Parameters:
T- the type parameter- Parameters:
type- the target typedefaultValue- the default value if conversion fails or value is null- Returns:
- the converted value or the default
-
node
Navigates to a child node by path segments.If the path doesn't exist, returns a virtual (empty) node.
- Parameters:
path- the path segments (strings for map keys, integers for list indices)- Returns:
- the child node, never null
-
node
Navigates to a child node by a property path.If the path doesn't exist, returns a virtual (empty) node.
- Parameters:
path- thePropertyPathto navigate to- Returns:
- the child node, never null
-
hasChild
Checks if this node has a child at the given path.- Parameters:
path- the path segments- Returns:
- true if the child exists and is not virtual
-
childrenMap
Gets all children as a map (for map nodes).- Returns:
- the children map, or empty map if not a map node
-
childrenList
Gets all children as a list (for list nodes).- Returns:
- the children list, or empty list if not a list node
-
isMap
boolean isMap()Checks if this node is a map (object) node.- Returns:
- true if this node contains key-value pairs
-
isList
boolean isList()Checks if this node is a list (array) node.- Returns:
- true if this node contains a list of values
-
isScalar
boolean isScalar()Checks if this node is a scalar (primitive/string) value.- Returns:
- true if this node contains a scalar value
-
isNull
boolean isNull()Checks if this node's value is null.- Returns:
- true if the value is null
-
isVirtual
boolean isVirtual()Checks if this node is virtual (doesn't exist in the source).Virtual nodes are returned when navigating to non-existent paths.
- Returns:
- true if this node is virtual
-
path
Gets the path to this node from root.- Returns:
- the path to this node
-