= TreeAdapter
: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.

Provides the parent/child relationship information between pojos to derive a tree-structure.

== API

[source,java]
.TreeAdapter.java
----
interface TreeAdapter<T> {
  int childCountOf(T value)     // <.>
  Stream<T> childrenOf(T value)     // <.>
  Optional<T> resolveRelative(T node, TreePath relativePath)     // <.>
  TreeAdapter<R> convert(TreeConverter<T, R> converter)     // <.>
}
----

<.> xref:#childCountOf_T[childCountOf(T)]
<.> xref:#childrenOf_T[childrenOf(T)]
<.> xref:#resolveRelative_T_TreePath[resolveRelative(T, TreePath)]
+
--
Resolves given xref:refguide:applib:index/graph/tree/TreePath.adoc[TreePath] to its corresponding sub-node relative to given node if possible.
--
<.> xref:#convert_TreeConverter[convert(TreeConverter)]
+
--
converts this _TreeAdapter_ to an equivalent _TreeAdapter_
--

== Members

[#childCountOf_T]
=== childCountOf(T)

[#childrenOf_T]
=== childrenOf(T)

[#resolveRelative_T_TreePath]
=== resolveRelative(T, TreePath)

Resolves given xref:refguide:applib:index/graph/tree/TreePath.adoc[TreePath] to its corresponding sub-node relative to given node if possible.

E.g. starting from root, '/0' will return the root;starting from root, '/0/2' will return the 3rd child of root;starting from sub-node '/0/2', '/2/9' will resolve the 10th child ('/0/2/9') of this sub-node

[#convert_TreeConverter]
=== convert(TreeConverter)

converts this _TreeAdapter_ to an equivalent _TreeAdapter_
