Package com.google.ar.sceneform
Class NodeParent
- java.lang.Object
-
- com.google.ar.sceneform.NodeParent
-
-
Constructor Summary
Constructors Constructor Description NodeParent()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addChild(Node child)
Adds a node as a child of this NodeParent.void
callOnHierarchy(java.util.function.Consumer<Node> consumer)
Traverse the hierarchy and call a method on each node.Node
findByName(java.lang.String name)
Traverse the hierarchy to find the first node with a given name.Node
findInHierarchy(java.util.function.Predicate<Node> condition)
Traverse the hierarchy to find the first node that meets a condition.java.util.List<Node>
getChildren()
Returns an immutable list of this parent's children.void
removeChild(Node child)
Removes a node from the children of this NodeParent.
-
-
-
Method Detail
-
getChildren
public final java.util.List<Node> getChildren()
Returns an immutable list of this parent's children.
-
addChild
public final void addChild(Node child)
Adds a node as a child of this NodeParent. If the node already has a parent, it is removed from its old parent. If the node is already a direct child of this NodeParent, no change is made.- Parameters:
child
- the node to add as a child- Throws:
java.lang.IllegalArgumentException
- if the child is the same object as the parent, or if the parent is a descendant of the child
-
removeChild
public final void removeChild(Node child)
Removes a node from the children of this NodeParent. If the node is not a direct child of this NodeParent, no change is made.- Parameters:
child
- the node to remove from the children
-
callOnHierarchy
public void callOnHierarchy(java.util.function.Consumer<Node> consumer)
Traverse the hierarchy and call a method on each node. Traversal is depth first. If this NodeParent is a Node, traversal starts with this NodeParent, otherwise traversal starts with its children.- Parameters:
consumer
- The method to call on each node.
-
findInHierarchy
@Nullable public Node findInHierarchy(java.util.function.Predicate<Node> condition)
Traverse the hierarchy to find the first node that meets a condition. Traversal is depth first. If this NodeParent is a Node, traversal starts with this NodeParent, otherwise traversal starts with its children.- Parameters:
condition
- predicate the defines the conditions of the node to search for.- Returns:
- the first node that matches the conditions of the predicate, otherwise null is returned
-
findByName
@Nullable public Node findByName(java.lang.String name)
Traverse the hierarchy to find the first node with a given name. Traversal is depth first. If this NodeParent is a Node, traversal starts with this NodeParent, otherwise traversal starts with its children.- Parameters:
name
- The name of the node to find- Returns:
- the node if it's found, otherwise null
-
-