public interface NodeCollection extends Collection<ConfigNode>
Collection implementation for use with nodes.
Note: This is not a general-purpose collection. Mutating methods in this class will mutate external state.
Elements in a node collection are considered children of the same tree. For this reason, each element of a node collection must have a distinct name. Mutating methods in this class will also update the parent field of added and removed elements.
The iterator returned by the iterator method traverses the
elements in ascending name order (ie. lexicographic order of the nodes' names).
Null elements are not permitted. Attempts to insert a null element
will throw a NullPointerException. Attempts to test for the
presence of a null element or to remove one will, however, function
properly.
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(ConfigNode child)
Attempts to introduce a new child to this collection.
|
boolean |
add(ConfigNode child,
boolean overwrite)
Attempts to introduce a new child to this collection.
|
ConfigNode |
getByName(String name)
Tries to find a child in this collection by name.
|
boolean |
remove(Object child)
Removes a child from this collection.
|
ConfigNode |
removeByName(String name)
Attempts to remove an item from this collection by name.
|
addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, parallelStream, removeAll, removeIf, retainAll, size, spliterator, stream, toArray, toArrayboolean add(ConfigNode child) throws DuplicateChildException
This method behaves as if add(node, false).
add in interface Collection<ConfigNode>child - The child to addtrue (as specified by Collection.add(E))DuplicateChildException - if there was already a child by the same nameIllegalStateException - if the child cannot be added to this tree at this timeNullPointerException - if node is nullboolean add(ConfigNode child, boolean overwrite) throws DuplicateChildException
If this method returns normally, the child will be attached
to this collection's owner.
child - The child to addoverwrite - whether existing items with the same name should be overwrittentrue (as specified by Collection.add(E))DuplicateChildException - if there exists a child by the same name that was not overwrittenIllegalStateException - if the child cannot be added to this tree at this timeNullPointerException - if node is nullConfigNode.attachTo(ConfigBranch)boolean remove(Object child)
When this method returns, the child will be detached from
this collection's owner. If the given object is not contained within this
collection, this method returns false with no side effects.
remove in interface Collection<ConfigNode>child - the child to removetrue if a node was detached as a result of this callConfigNode.detach()ConfigNode getByName(String name)
name - The name of the child to look fornull@Nullable ConfigNode removeByName(String name)
name - the name of the child that should be removednull