public interface HasParentNode<T> extends Observable
Modifier and Type | Method and Description |
---|---|
default <N> Optional<N> |
findAncestor(Class<N> type)
Walks the parents of this node and returns the first node of type
type , or empty() if none is
found. |
default <N> Optional<N> |
findAncestor(Class<N> type,
Predicate<N> predicate)
Walks the parents of this node and returns the first node of type
type that matches predicate , or
empty() if none is found. |
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.
|
default boolean |
isDescendantOf(Node ancestor)
Determines whether this
HasParentNode node is a descendant of the given node. |
T |
setParentNode(Node parentNode)
Sets the parent node.
|
isRegistered, register, unregister
Optional<Node> getParentNode()
Optional.empty
if no parent is set.T setParentNode(Node parentNode)
parentNode
- the parent node, or null
to set no parent.this
Node getParentNodeForChildren()
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).
default <N> Optional<N> findAncestor(Class<N> type)
type
, or empty()
if none is
found. The given type may also be an interface type, such as one of the NodeWith...
interface types.default <N> Optional<N> findAncestor(Class<N> type, Predicate<N> predicate)
type
that matches predicate
, or
empty()
if none is found. The given type may also be an interface type, such as one of the
NodeWith...
interface types.default boolean isDescendantOf(Node ancestor)
HasParentNode
node is a descendant of the given node. A node is not a
descendant of itself.ancestor
- the node for which to determine whether it has this node as an ancestor.true
if this node is a descendant of the given node, and false
otherwise.Node.isAncestorOf(Node)
Copyright © 2007–2020. All rights reserved.