Package org.apache.sis.util.collection

# Interface TreeTable

All Known Implementing Classes:
  `DefaultTreeTable`

public interface TreeTable
Defines the structure (list of columns) of a table and provides the root of the tree containing the data. `TreeTable` can be seen as a table in which the first column contains a tree. Every row in this table is a `TreeTable​.Node` instance, and each node can have an arbitrary number of children nodes.

Below is an example of what a two-columns `TreeTable` instance may look like when formatted as a text:

>     Citation
>       ├─Title…………………………………………………………… Open Geospatial Consortium
>       ├─Presentation Forms………………………… document digital
>       ├─Cited Responsible Parties
>       │   ├─Organisation Name………………… Open Geospatial Consortium
>       │   ├─Role…………………………………………………… resource provider
>       │   └─Contact Info
>       │       └─Online Resource
>       │           ├─Linkage……………………… https://www.ogc.org/
>       │           └─Function…………………… information
>       └─Identifiers
>           └─Code…………………………………………………… OGC

In many cases, the columns are known in advance as hard-coded static constants. Those column constants are typically documented close to the class producing the `TreeTable` instance. Using directly those static constants provides type safety, as in the following example:

>     TreeTable table = ...; // Put here a TreeTable instance.
>     TreeTable.Node node = table.getRoot();
>     CharSequence   name = node.getValue(TableColumn.NAME);
>     Class<?>       type = node.getValue(TableColumn.TYPE);

In the above example, the type of value returned by the `TreeTable​.Node​.getValue(TableColumn)` method is determined by the column constant. However this approach is possible only when the table structure is known in advance. If a method needs to work with arbitrary tables, then that method can get the list of columns by a call to `getColumns()`. However this column list does not provide the above type-safety.

Since:
  0.3

Defined in the `sis-utility` module

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Interface
  Description
  `static interface`
  `TreeTable​.Node`
  A node in a tree combined with a row in a table.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `List<TableColumn<?>>`
  `getColumns()`
  Returns the table columns, in the order they shall be rendered by default.
  `TreeTable​.Node`
  `getRoot()`
  Returns the root node of the tree.

- ## Method Details

  - ### getColumns

    List<TableColumn<?>> getColumns()
    Returns the table columns, in the order they shall be rendered by default. This method returns the union of all table columns in every nodes of this tree. However any `TreeTable​.Node` instance can return `null` for a particular column if the node doesn't have that column.
    Returns:
      the union of all table columns in every tree node.
    See Also:
      - `TreeTable​.Node​.getValue(TableColumn)`
      - `TreeTable​.Node​.setValue(TableColumn, Object)`

  - ### getRoot

    TreeTable.Node getRoot()
    Returns the root node of the tree.
    Returns:
      the root node of the tree.