N
- the type of nodes contained.public class NodeList<N extends Node> extends Object implements List<N>, Iterable<N>, HasParentNode<NodeList<N>>, Visitable, Observable
Constructor and Description |
---|
NodeList() |
NodeList(Collection<N> n) |
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) |
NodeList<N> |
addAfter(N node,
N afterThisNode)
Inserts the node after afterThisNode.
|
boolean |
addAll(Collection<? extends N> c) |
boolean |
addAll(int index,
Collection<? extends N> c) |
void |
addAll(NodeList<N> otherList) |
NodeList<N> |
addBefore(N node,
N beforeThisNode)
Inserts the node before beforeThisNode.
|
NodeList<N> |
addFirst(N node)
Inserts the node before all other nodes.
|
NodeList<N> |
addLast(N node)
Inserts the node after all other nodes.
|
void |
clear() |
boolean |
contains(N node) |
boolean |
contains(Object o) |
boolean |
containsAll(Collection<?> c) |
boolean |
equals(Object o) |
void |
forEach(Consumer<? super N> action) |
N |
get(int i) |
Optional<N> |
getFirst() |
Optional<N> |
getLast() |
Optional<Node> |
getParentNode()
Returns the parent node, or
Optional.empty if no parent is set. |
Node |
getParentNodeForChildren()
Returns the parent node from the perspective of the children of this node.
|
int |
hashCode() |
void |
ifNonEmpty(Consumer<? super NodeList<N>> consumer) |
int |
indexOf(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.
|
Iterator<N> |
iterator() |
int |
lastIndexOf(Object o) |
ListIterator<N> |
listIterator() |
ListIterator<N> |
listIterator(int index) |
static <X extends Node> |
nodeList(Collection<X> nodes) |
static <X extends Node> |
nodeList(NodeList<X> nodes) |
static <X extends Node> |
nodeList(X... nodes) |
Stream<N> |
parallelStream() |
void |
register(AstObserver observer)
Register an observer.
|
N |
remove(int index) |
boolean |
remove(Node node) |
boolean |
remove(Object o) |
boolean |
removeAll(Collection<?> c) |
N |
removeFirst() |
boolean |
removeIf(Predicate<? super N> filter) |
N |
removeLast() |
boolean |
replace(N old,
N replacement)
Replaces the first node that is equal to "old" with "replacement".
|
void |
replaceAll(UnaryOperator<N> operator) |
boolean |
retainAll(Collection<?> c) |
N |
set(int index,
N element) |
NodeList<N> |
setParentNode(Node parentNode)
Sets the parentNode
|
int |
size() |
void |
sort(Comparator<? super N> comparator) |
Spliterator<N> |
spliterator() |
List<N> |
subList(int fromIndex,
int toIndex) |
Object[] |
toArray() |
<T> T[] |
toArray(T[] a) |
static <T extends Node> |
toNodeList() |
String |
toString() |
void |
unregister(AstObserver observer)
Unregister an observer.
|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
stream
findAncestor, findAncestor, isDescendantOf
public NodeList()
public NodeList(Collection<N> n)
@SafeVarargs public NodeList(N... n)
public boolean add(N node)
public boolean remove(Node node)
public N removeFirst()
public N removeLast()
@SafeVarargs public static <X extends Node> NodeList<X> nodeList(X... nodes)
public static <X extends Node> NodeList<X> nodeList(Collection<X> nodes)
public boolean contains(N node)
public int size()
public boolean isEmpty()
public void sort(Comparator<? super N> comparator)
public NodeList<N> addLast(N node)
public NodeList<N> addAfter(N node, N afterThisNode)
IllegalArgumentException
- when afterThisNode is not in this list.public NodeList<N> addBefore(N node, N beforeThisNode)
IllegalArgumentException
- when beforeThisNode is not in this list.public Optional<Node> getParentNode()
HasParentNode
Optional.empty
if no parent is set.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
That is, this method returns this
for everything except NodeList
. A NodeList
returns its
parent node instead. This is because a NodeList
sets the parent of all its children to its own parent
node (see NodeList
for details).
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(Consumer<? super N> action)
forEach
in interface Iterable<N extends Node>
Iterable.forEach(java.util.function.Consumer)
public boolean contains(Object o)
contains
in interface Collection<N extends Node>
contains
in interface List<N extends Node>
List.contains(java.lang.Object)
public Object[] toArray()
toArray
in interface Collection<N extends Node>
toArray
in interface List<N extends Node>
List.toArray()
public <T> T[] toArray(T[] a)
toArray
in interface Collection<N extends Node>
toArray
in interface List<N extends Node>
List.toArray(java.lang.Object[])
public boolean remove(Object o)
remove
in interface Collection<N extends Node>
remove
in interface List<N extends Node>
List.remove(java.lang.Object)
public boolean containsAll(Collection<?> c)
containsAll
in interface Collection<N extends Node>
containsAll
in interface List<N extends Node>
List.containsAll(java.util.Collection)
public boolean addAll(Collection<? extends N> c)
addAll
in interface Collection<N extends Node>
addAll
in interface List<N extends Node>
List.addAll(java.util.Collection)
public boolean addAll(int index, Collection<? extends N> c)
addAll
in interface List<N extends Node>
List.addAll(int, java.util.Collection)
public boolean removeAll(Collection<?> c)
removeAll
in interface Collection<N extends Node>
removeAll
in interface List<N extends Node>
List.removeAll(java.util.Collection)
public boolean retainAll(Collection<?> c)
retainAll
in interface Collection<N extends Node>
retainAll
in interface List<N extends Node>
List.retainAll(java.util.Collection)
public void replaceAll(UnaryOperator<N> operator)
replaceAll
in interface List<N extends Node>
List.replaceAll(java.util.function.UnaryOperator)
public boolean removeIf(Predicate<? super N> filter)
removeIf
in interface Collection<N extends Node>
Collection.removeIf(java.util.function.Predicate)
public void clear()
clear
in interface Collection<N extends Node>
clear
in interface List<N extends Node>
List.clear()
public boolean equals(Object o)
public int hashCode()
public int indexOf(Object o)
indexOf
in interface List<N extends Node>
List.indexOf(java.lang.Object)
public int lastIndexOf(Object o)
lastIndexOf
in interface List<N extends Node>
List.lastIndexOf(java.lang.Object)
public ListIterator<N> listIterator()
listIterator
in interface List<N extends Node>
List.listIterator()
public ListIterator<N> listIterator(int index)
listIterator
in interface List<N extends Node>
List.listIterator(int)
public Stream<N> parallelStream()
parallelStream
in interface Collection<N extends Node>
Collection.parallelStream()
public List<N> subList(int fromIndex, int toIndex)
subList
in interface List<N extends Node>
List.subList(int, int)
public Spliterator<N> spliterator()
spliterator
in interface Iterable<N extends Node>
spliterator
in interface Collection<N extends Node>
spliterator
in interface List<N extends Node>
List.spliterator()
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()
Copyright © 2007–2020. All rights reserved.