N
- the type of nodes contained.public class NodeList<N extends Node> extends java.lang.Object implements java.util.List<N>, java.lang.Iterable<N>, HasParentNode<NodeList<N>>, Visitable, Observable
Modifier and Type | Field and Description |
---|---|
private java.util.List<N> |
innerList |
private java.util.List<AstObserver> |
observers |
private Node |
parentNode |
Constructor and Description |
---|
NodeList() |
NodeList(Node parent) |
NodeList(NodeList<N> n) |
Modifier and Type | Method and Description |
---|---|
<R,A> R |
accept(GenericVisitor<R,A> v,
A arg)
Accept method for visitor support.
|
<A> void |
accept(VoidVisitor<A> v,
A arg)
Accept method for visitor support.
|
void |
add(int index,
N node) |
boolean |
add(N node) |
boolean |
addAll(java.util.Collection<? extends N> c) |
boolean |
addAll(int index,
java.util.Collection<? extends N> c) |
void |
addAll(NodeList<N> otherList) |
void |
clear() |
boolean |
contains(N node) |
boolean |
contains(java.lang.Object o) |
boolean |
containsAll(java.util.Collection<?> c) |
boolean |
equals(java.lang.Object o) |
void |
forEach(java.util.function.Consumer<? super N> action) |
N |
get(int i) |
java.util.Optional<Node> |
getParentNode()
Return the parent node or null, if no parent is set.
|
Node |
getParentNodeForChildren()
this for everything except NodeLists.
|
int |
hashCode() |
void |
ifNonEmpty(java.util.function.Consumer<? super NodeList<N>> consumer) |
int |
indexOf(java.lang.Object o) |
boolean |
isEmpty() |
boolean |
isNonEmpty() |
boolean |
isRegistered(AstObserver observer)
Was this observer registered?
Note that equals is used to determine if the given observer was registered.
|
java.util.Iterator<N> |
iterator() |
int |
lastIndexOf(java.lang.Object o) |
java.util.ListIterator<N> |
listIterator() |
java.util.ListIterator<N> |
listIterator(int index) |
static <X extends Node> |
nodeList(java.util.Collection<X> nodes) |
static <X extends Node> |
nodeList(NodeList<X> nodes) |
static <X extends Node> |
nodeList(X... nodes) |
private void |
notifyElementAdded(int index,
Node nodeAddedOrRemoved) |
private void |
notifyElementRemoved(int index,
Node nodeAddedOrRemoved) |
private void |
notifyElementReplaced(int index,
Node nodeAddedOrRemoved) |
private void |
own(N node) |
java.util.stream.Stream<N> |
parallelStream() |
void |
register(AstObserver observer)
Register an observer.
|
N |
remove(int index) |
boolean |
remove(Node node) |
boolean |
remove(java.lang.Object o) |
boolean |
removeAll(java.util.Collection<?> c) |
boolean |
removeIf(java.util.function.Predicate<? super N> filter) |
boolean |
replace(N old,
N replacement)
Replaces the first node that is equal to "old" with "replacement".
|
void |
replaceAll(java.util.function.UnaryOperator<N> operator) |
boolean |
retainAll(java.util.Collection<?> c) |
N |
set(int index,
N element) |
private void |
setAsParentNodeOf(java.util.List<? extends Node> childNodes) |
private void |
setAsParentNodeOf(Node childNode) |
NodeList<N> |
setParentNode(Node parentNode)
Sets the parentNode
|
int |
size() |
void |
sort(java.util.Comparator<? super N> comparator) |
java.util.Spliterator<N> |
spliterator() |
java.util.List<N> |
subList(int fromIndex,
int toIndex) |
java.lang.Object[] |
toArray() |
<T> T[] |
toArray(T[] a) |
static <T extends Node> |
toNodeList() |
java.lang.String |
toString() |
void |
unregister(AstObserver observer)
Unregister an observer.
|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
getAncestorOfType
private Node parentNode
private java.util.List<AstObserver> observers
public NodeList()
public NodeList(Node parent)
public boolean add(N node)
private void own(N node)
public boolean remove(Node node)
public boolean contains(N node)
public int size()
public java.util.Iterator<N> iterator()
public boolean isEmpty()
public void sort(java.util.Comparator<? super N> comparator)
public void add(int index, N node)
public java.util.Optional<Node> getParentNode()
HasParentNode
getParentNode
in interface HasParentNode<NodeList<N extends Node>>
public NodeList<N> setParentNode(Node parentNode)
setParentNode
in interface HasParentNode<NodeList<N extends Node>>
parentNode
- the parentNodepublic Node getParentNodeForChildren()
HasParentNode
getParentNodeForChildren
in interface HasParentNode<NodeList<N extends Node>>
public <R,A> R accept(GenericVisitor<R,A> v, A arg)
Visitable
accept
in interface Visitable
R
- the type of the return value of the visitorA
- the type the user argument passed to the visitorv
- the visitor implementationarg
- the argument passed to the visitor (of type A)public <A> void accept(VoidVisitor<A> v, A arg)
Visitable
public void forEach(java.util.function.Consumer<? super N> action)
public boolean contains(java.lang.Object o)
public java.lang.Object[] toArray()
public <T> T[] toArray(T[] a)
public boolean remove(java.lang.Object o)
public boolean containsAll(java.util.Collection<?> c)
public boolean addAll(java.util.Collection<? extends N> c)
public boolean addAll(int index, java.util.Collection<? extends N> c)
public boolean removeAll(java.util.Collection<?> c)
public boolean retainAll(java.util.Collection<?> c)
public void replaceAll(java.util.function.UnaryOperator<N> operator)
public boolean removeIf(java.util.function.Predicate<? super N> filter)
public void clear()
public boolean equals(java.lang.Object o)
public int hashCode()
public int indexOf(java.lang.Object o)
public int lastIndexOf(java.lang.Object o)
public java.util.ListIterator<N> listIterator()
public java.util.ListIterator<N> listIterator(int index)
public java.util.stream.Stream<N> parallelStream()
public java.util.List<N> subList(int fromIndex, int toIndex)
public java.util.Spliterator<N> spliterator()
private void notifyElementAdded(int index, Node nodeAddedOrRemoved)
private void notifyElementRemoved(int index, Node nodeAddedOrRemoved)
private void notifyElementReplaced(int index, Node nodeAddedOrRemoved)
public void unregister(AstObserver observer)
Observable
unregister
in interface Observable
public void register(AstObserver observer)
Observable
register
in interface Observable
public boolean isRegistered(AstObserver observer)
Observable
isRegistered
in interface Observable
public boolean replace(N old, N replacement)
public boolean isNonEmpty()
public static <T extends Node> java.util.stream.Collector<T,NodeList<T>,NodeList<T>> toNodeList()
private void setAsParentNodeOf(java.util.List<? extends Node> childNodes)
private void setAsParentNodeOf(Node childNode)
public java.lang.String toString()
toString
in class java.lang.Object