Package org.spongepowered.configurate
Interface NodePath
-
- All Superinterfaces:
java.lang.Iterable<java.lang.Object>
public interface NodePath extends java.lang.Iterable<java.lang.Object>
Represents the path to a given node.- Since:
- 4.0.0
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description java.lang.Object[]array()Returns a copy of the original path array.NodePathcopy()Create a new node path with the same data as this path.java.lang.Objectget(int i)Gets a specific element from the path array.java.util.Iterator<java.lang.Object>iterator()Returns an iterator over the path.static NodePathof(java.lang.Object[] path)Create a node path reference.static NodePathof(java.util.Collection<?> path)Create a node path reference.static NodePathpath()Get an empty node path.static NodePathpath(java.lang.Object... elements)Create a node path reference.NodePathplus(NodePath other)Create a new path from the combination ofthisandother.intsize()Gets the length of the path.NodePathwith(int index, java.lang.Object value)Create a new path with the value atindexreplaced withvalue.NodePathwithAppendedChild(java.lang.Object childKey)Create a new path with the provided element appended to the end.
-
-
-
Method Detail
-
of
static NodePath of(java.lang.Object[] path)
Create a node path reference.- Parameters:
path- the path to reference. The provided array will be copied.- Returns:
- the path instance
- Since:
- 4.0.0
-
of
static NodePath of(java.util.Collection<?> path)
Create a node path reference.- Parameters:
path- a collection containing elements of the path to reference- Returns:
- the path instance
- Since:
- 4.0.0
-
path
static NodePath path(java.lang.Object... elements)
Create a node path reference.This overload takes varargs, and is designed to be imported statically to create paths.
- Parameters:
elements- the path to reference. The provided array will be copied.- Returns:
- the path instance
- Since:
- 4.0.0
-
path
static NodePath path()
Get an empty node path. This refers to the root node.- Returns:
- the empty path
- Since:
- 4.0.0
-
get
java.lang.Object get(int i)
Gets a specific element from the path array.- Parameters:
i- the index to get- Returns:
- object at the index
- Since:
- 4.0.0
-
size
int size()
Gets the length of the path.- Returns:
- length of the path array
- Since:
- 4.0.0
-
array
java.lang.Object[] array()
Returns a copy of the original path array.- Returns:
- the copied array
- Since:
- 4.0.0
-
withAppendedChild
NodePath withAppendedChild(java.lang.Object childKey)
Create a new path with the provided element appended to the end.- Parameters:
childKey- the new key to append- Returns:
- a new path object reflecting the extended path
- Since:
- 4.0.0
-
with
NodePath with(int index, java.lang.Object value) throws java.lang.IndexOutOfBoundsException
Create a new path with the value atindexreplaced withvalue.- Parameters:
index- position to changevalue- value to insert- Returns:
- new path object with changed value
- Throws:
java.lang.IndexOutOfBoundsException- if index < 0 or ≥ size()- Since:
- 4.0.0
-
plus
NodePath plus(NodePath other)
Create a new path from the combination ofthisandother.- Parameters:
other- the path to append- Returns:
- a new path, containing the elements of this path followed by the
elements of
other. - Since:
- 4.1.0
-
iterator
java.util.Iterator<java.lang.Object> iterator()
Returns an iterator over the path.- Specified by:
iteratorin interfacejava.lang.Iterable<java.lang.Object>- Returns:
- an iterator of the path elements
- Since:
- 4.0.0
-
-