Package ch.njol.skript.config
Interface NodeNavigator
- All Known Implementing Classes:
Config
,EntryNode
,InvalidNode
,Node
,SectionNode
,SimpleNode
,VoidNode
Something that contains or references nodes and can be navigated.
Not all navigation options are universally-supported.
All nodes are node navigators, even if they are
All nodes are node navigators, even if they are
EntryNode
s that do not support
children.
Entry nodes will return null
for all child-based operations
(as if the requested node was simply not present).-
Method Summary
Modifier and TypeMethodDescription@Nullable Node
Obtains the immediate child node at this (direct) key.@NotNull Node
Obtains the current node represented by this navigator.default @Nullable Node
Fetches a node at position inside the current node.default @Nullable Node
Fetches a node at a path inside the current node.default @Nullable String
Gets the raw value from the node at the given path.iterator()
If this navigator represents a node with no children (e.g.Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Method Details
-
iterator
If this navigator represents a node with no children (e.g. an entry node) this iterator will be empty. -
get
Obtains the immediate child node at this (direct) key. If this does not represent a node that can have children (e.g. anEntryNode
) then it must returnnull
.- Parameters:
key
- The name of the node- Returns:
- The child node if one is present, otherwise
null
-
getCurrentNode
Obtains the current node represented by this navigator. If this navigator is itself a node, it should return itself.- Returns:
- The main node represented by this navigator
-
getNodeAt
Fetches a node at position inside the current node. If any stage represents a node with no children (e.g. an entry node) the result will be null.
In the following example, the two entry nodes can be obtained from the root with"first", "one"
and"first", "two", "three"
(respectively).first: one: value two: three: value
- Parameters:
steps
- The node steps to traverse- Returns:
- The node at the final step (or nothing)
-
getNodeAt
@Contract("null -> this") @Nullable default @Nullable Node getNodeAt(@Nullable @Nullable String path) Fetches a node at a path inside the current node. If any stage represents a node with no children (e.g. an entry node) the result will be null.
In the following example, the two entry nodes can be obtained from the root with"first.one"
and"first.two.three"
(respectively).first: one: value two: three: value
If the path isnull
or empty, this node will be returned.- Parameters:
path
- The path to the node, separated by.
- Returns:
- The node at the path (or nothing)
- See Also:
-
getValue
Gets the raw value from the node at the given path. If any part of the path is invalid, this will return null.- Parameters:
path
- The node path from which to get the value- Returns:
- If such a node exists, its value, otherwise null
-