= TreeNode
:Notice: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at. http://www.apache.org/licenses/LICENSE-2.0 . Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR  CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Fundamental building block of Tree structures.

== API

[source,java]
.TreeNode.java
----
class TreeNode<T> {
  TreeNode<T> root(T value, TreeAdapter<T> treeAdapter, TreeState sharedState)
  TreeNode<T> root(T value, Class<? extends TreeAdapter<T>> treeAdapterClass, TreeState sharedState, FactoryService factoryService)
  T getRootValue()
  T getValue()
  int getIncomingCount()
  int getOutgoingCount()
  Stream<Edge<T>> streamIncoming()
  Stream<Edge<T>> streamOutgoing()
  Optional<TreeNode<T>> resolve(TreePath absolutePath)     // <.>
  Optional<TreeNode<T>> lookupParent()
  int getChildCount()
  Stream<TreeNode<T>> streamChildren()
  boolean isLeaf()
  TreePath getPositionAsPath()
  TreeState getTreeState()     // <.>
  boolean isExpanded(TreePath treePath)
  void expand(TreePath... treePaths)     // <.>
  void expand()     // <.>
  void collapse(TreePath... treePaths)     // <.>
  void clearSelection()     // <.>
  boolean isSelected(TreePath treePath)     // <.>
  void select(TreePath... treePaths)     // <.>
  TreeNode<T> root(T rootNode, TreeAdapter<T> treeAdapter)     // <.>
  TreeNode<T> root(T rootNode, Class<? extends TreeAdapter<T>> treeAdapterClass, FactoryService factoryService)     // <.>
  Iterator<TreeNode<T>> iteratorHierarchyUp()
  Stream<TreeNode<T>> streamHierarchyUp()
  Iterator<TreeNode<T>> iteratorDepthFirst()
  Iterator<TreeNode<T>> iteratorBreadthFirst()
  Stream<TreeNode<T>> streamDepthFirst()
  Stream<TreeNode<T>> streamBreadthFirst()
}
----

<.> xref:#resolve_TreePath[resolve(TreePath)]
+
--
Resolves given path relative to the root of this tree.
--
<.> xref:#getTreeState_[getTreeState()]
<.> xref:#expand_TreePath[expand(TreePath)]
+
--
Adds _treePaths_ to the set of expanded nodes, as held by this tree's shared state object.
--
<.> xref:#expand_[expand()]
+
--
Expands this node and all its parents.
--
<.> xref:#collapse_TreePath[collapse(TreePath)]
+
--
Removes _treePaths_ from the set of expanded nodes, as held by this tree's shared state object.
--
<.> xref:#clearSelection_[clearSelection()]
+
--
Clears all selection markers.
--
<.> xref:#isSelected_TreePath[isSelected(TreePath)]
+
--
Whether node that corresponds to given xref:refguide:applib:index/graph/tree/TreePath.adoc[TreePath] has a selection marker.
--
<.> xref:#select_TreePath[select(TreePath)]
+
--
Select nodes by their corresponding xref:refguide:applib:index/graph/tree/TreePath.adoc[TreePath] , that is, activate their selection marker.
--
<.> xref:#root_T_TreeAdapter[root(T, TreeAdapter)]
+
--
Creates the root node of a tree structure as inferred from given treeAdapter.
--
<.> xref:#root_T_Class_FactoryService[root(T, Class, FactoryService)]
+
--
Creates the root node of a tree structure as inferred from given treeAdapter.
--

== Members

[#resolve_TreePath]
=== resolve(TreePath)

Resolves given path relative to the root of this tree.

[#getTreeState_]
=== getTreeState()

[#expand_TreePath]
=== expand(TreePath)

Adds _treePaths_ to the set of expanded nodes, as held by this tree's shared state object.

[#expand_]
=== expand()

Expands this node and all its parents.

[#collapse_TreePath]
=== collapse(TreePath)

Removes _treePaths_ from the set of expanded nodes, as held by this tree's shared state object.

[#clearSelection_]
=== clearSelection()

Clears all selection markers.

[#isSelected_TreePath]
=== isSelected(TreePath)

Whether node that corresponds to given xref:refguide:applib:index/graph/tree/TreePath.adoc[TreePath] has a selection marker.

[#select_TreePath]
=== select(TreePath)

Select nodes by their corresponding xref:refguide:applib:index/graph/tree/TreePath.adoc[TreePath] , that is, activate their selection marker.

With the _Wicket Viewer_ corresponds to expressing CSS class _tree-node-selected_ on the rendered tree node, which has default bg-color _lightgrey_ . Color can be customized by setting CSS var __

----
.tree-theme-bootstrap .tree-node-selected {
    background-color: var(--tree-node-selected-bg-color, lightgrey);
}
----

[#root_T_TreeAdapter]
=== root(T, TreeAdapter)

Creates the root node of a tree structure as inferred from given treeAdapter.

[#root_T_Class_FactoryService]
=== root(T, Class, FactoryService)

Creates the root node of a tree structure as inferred from given treeAdapter.
