blob: 3041f7e1942e326f30a3604be17752b9a1c2d71e [file] [log] [blame]
<!DOCTYPE HTML>
<html lang="en">
<head>
<!-- Generated by javadoc (21) on Thu Oct 05 19:54:57 CEST 2023 -->
<title>TreeTable.Node (Apache SIS 1.4 API)</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="dc.created" content="2023-10-05">
<meta name="description" content="declaration: module: org.apache.sis.util, package: org.apache.sis.util.collection, interface: TreeTable, interface: Node">
<meta name="generator" content="javadoc/ClassWriterImpl">
<meta name="keywords" content="org.apache.sis.util.collection.TreeTable.Node interface">
<meta name="keywords" content="getParent()">
<meta name="keywords" content="isLeaf()">
<meta name="keywords" content="getChildren()">
<meta name="keywords" content="newChild()">
<meta name="keywords" content="getValue()">
<meta name="keywords" content="setValue()">
<meta name="keywords" content="isEditable()">
<meta name="keywords" content="getUserObject()">
<meta name="keywords" content="equals()">
<meta name="keywords" content="hashCode()">
<link rel="stylesheet" type="text/css" href="../../../../../../stylesheet.css" title="Style">
<link rel="stylesheet" type="text/css" href="../../../../../../sis.css" title="Style">
<link rel="stylesheet" type="text/css" href="../../../../../../script-dir/jquery-ui.min.css" title="Style">
<script type="text/javascript" src="../../../../../../script.js"></script>
<script type="text/javascript" src="../../../../../../script-dir/jquery-3.6.1.min.js"></script>
<script type="text/javascript" src="../../../../../../script-dir/jquery-ui.min.js"></script>
</head>
<body class="class-declaration-page">
<script type="text/javascript">var pathtoroot = "../../../../../../";
loadScripts(document, 'script');</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<div class="flex-box">
<header role="banner" class="flex-header">
<nav role="navigation">
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="top-nav" id="navbar-top"><button id="navbar-toggle-button" aria-controls="navbar-top" aria-expanded="false" aria-label="Toggle navigation links"><span class="nav-bar-toggle-icon">&nbsp;</span><span class="nav-bar-toggle-icon">&nbsp;</span><span class="nav-bar-toggle-icon">&nbsp;</span></button>
<div class="skip-nav"><a href="#skip-navbar-top" title="Skip navigation links">Skip navigation links</a></div>
<ul id="navbar-top-firstrow" class="nav-list" title="Navigation">
<li><a href="../../../../../../index.html">Overview</a></li>
<li><a href="../../../../../module-summary.html">Module</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="nav-bar-cell1-rev">Class</li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../../../index-all.html">Index</a></li>
<li><a href="../../../../../../help-doc.html#class">Help</a></li>
</ul>
<ul class="sub-nav-list-small">
<li>
<p>Summary:</p>
<ul>
<li>Nested</li>
<li>Field</li>
<li>Constr</li>
<li><a href="#method-summary">Method</a></li>
</ul>
</li>
<li>
<p>Detail:</p>
<ul>
<li>Field</li>
<li>Constr</li>
<li><a href="#method-detail">Method</a></li>
</ul>
</li>
</ul>
</div>
<div class="sub-nav">
<div id="navbar-sub-list">
<ul class="sub-nav-list">
<li>Summary:&nbsp;</li>
<li>Nested&nbsp;|&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li>Constr&nbsp;|&nbsp;</li>
<li><a href="#method-summary">Method</a></li>
</ul>
<ul class="sub-nav-list">
<li>Detail:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li>Constr&nbsp;|&nbsp;</li>
<li><a href="#method-detail">Method</a></li>
</ul>
</div>
<div class="nav-list-search"><a href="../../../../../../search.html">SEARCH</a>
<input type="text" id="search-input" disabled placeholder="Search">
<input type="reset" id="reset-button" disabled value="reset">
</div>
</div>
<!-- ========= END OF TOP NAVBAR ========= -->
<span class="skip-nav" id="skip-navbar-top"></span></nav>
</header>
<div class="flex-content">
<main role="main">
<!-- ======== START OF CLASS DATA ======== -->
<div class="header">
<div class="sub-title"><span class="module-label-in-type">Module</span>&nbsp;<a href="../../../../../module-summary.html">org.apache.sis.util</a></div>
<div class="sub-title"><span class="package-label-in-type">Package</span>&nbsp;<a href="package-summary.html">org.apache.sis.util.collection</a></div>
<h1 title="Interface TreeTable.Node" class="title">Interface TreeTable.Node</h1>
</div>
<section class="class-description" id="class-description">
<dl class="notes">
<dt>All Known Implementing Classes:</dt>
<dd><code><a href="DefaultTreeTable.Node.html" title="class in org.apache.sis.util.collection">Default­Tree­Table​.Node</a></code></dd>
</dl>
<dl class="notes">
<dt>Enclosing interface:</dt>
<dd><code><a href="TreeTable.html" title="interface in org.apache.sis.util.collection">Tree­Table</a></code></dd>
</dl>
<hr>
<div class="type-signature"><span class="modifiers">public static interface </span><span class="element-name type-name-label">TreeTable.Node</span></div>
<div class="block">A node in a tree combined with a row in a table. A <code>Tree­Table​.Node</code> can be seen as a
tree node associated to a single <a href="#getUserObject()">user object</a> (like ordinary trees),
augmented with the capability to describe some aspects of the user object in predefined columns.
The list of allowed columns is given by the <a href="TreeTable.html#getColumns()"><code>Tree­Table​.get­Columns()</code></a> method.
<p>The following table summarizes the tree-related and table-related methods:</p>
<table class="sis">
<caption>Tree-table methods</caption>
<tr>
<th>Tree-related methods</th>
<th>Table-related methods</th>
</tr>
<tr><td><ul>
<li><a href="#getParent()"><code>get­Parent()</code></a></li>
<li><a href="#getChildren()"><code>get­Children()</code></a></li>
<li><a href="#newChild()"><code>new­Child()</code></a></li>
</ul></td>
<td><ul>
<li><a href="#getValue(org.apache.sis.util.collection.TableColumn)"><code>get­Value(Table­Column)</code></a></li>
<li><a href="#setValue(org.apache.sis.util.collection.TableColumn,V)"><code>set­Value(Table­Column, Object)</code></a></li>
<li><a href="#isEditable(org.apache.sis.util.collection.TableColumn)"><code>is­Editable(Table­Column)</code></a></li>
</ul></td></tr>
</table>
In addition, each <code>Node</code> can be associated to an arbitrary object by the
<a href="#getUserObject()"><code>get­User­Object()</code></a> method. This object is not used directly by the tree tables.</div>
<dl class="notes">
<dt>Since:</dt>
<dd>0.3</dd>
</dl>
</section>
<section class="summary">
<ul class="summary-list">
<!-- ========== METHOD SUMMARY =========== -->
<li>
<section class="method-summary" id="method-summary">
<h2>Method Summary</h2>
<div id="method-summary-table">
<div class="table-tabs" role="tablist" aria-orientation="horizontal"><button id="method-summary-table-tab0" role="tab" aria-selected="true" aria-controls="method-summary-table.tabpanel" tabindex="0" onkeydown="switchTab(event)" onclick="show('method-summary-table', 'method-summary-table', 3)" class="active-table-tab">All Methods</button><button id="method-summary-table-tab2" role="tab" aria-selected="false" aria-controls="method-summary-table.tabpanel" tabindex="-1" onkeydown="switchTab(event)" onclick="show('method-summary-table', 'method-summary-table-tab2', 3)" class="table-tab">Instance Methods</button><button id="method-summary-table-tab3" role="tab" aria-selected="false" aria-controls="method-summary-table.tabpanel" tabindex="-1" onkeydown="switchTab(event)" onclick="show('method-summary-table', 'method-summary-table-tab3', 3)" class="table-tab">Abstract Methods</button></div>
<div id="method-summary-table.tabpanel" role="tabpanel">
<div class="summary-table three-column-summary" aria-labelledby="method-summary-table-tab0">
<div class="table-header col-first">Modifier and Type</div>
<div class="table-header col-second">Method</div>
<div class="table-header col-last">Description</div>
<div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code>boolean</code></div>
<div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code><a href="#equals(java.lang.Object)" class="member-name-link">equals</a><wbr>(<a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Object.html" title="class or interface in java.lang" class="external-link">Object</a>&nbsp;other)</code></div>
<div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3">
<div class="block">Returns <code>true</code> if the given object is a node with the same content than this node.</div>
</div>
<div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/Collection.html" title="class or interface in java.util" class="external-link">Collection</a><wbr>&lt;<a href="TreeTable.Node.html" title="interface in org.apache.sis.util.collection">Tree­Table​.Node</a>&gt;</code></div>
<div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code><a href="#getChildren()" class="member-name-link">get­Children</a>()</code></div>
<div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3">
<div class="block">Returns the children of this node.</div>
</div>
<div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code><a href="TreeTable.Node.html" title="interface in org.apache.sis.util.collection">Tree­Table​.Node</a></code></div>
<div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code><a href="#getParent()" class="member-name-link">get­Parent</a>()</code></div>
<div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3">
<div class="block">Returns the parent node, or <code>null</code> if this node is the root of the tree.</div>
</div>
<div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Object.html" title="class or interface in java.lang" class="external-link">Object</a></code></div>
<div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code><a href="#getUserObject()" class="member-name-link">get­User­Object</a>()</code></div>
<div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3">
<div class="block">Returns the user object associated to this node.</div>
</div>
<div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code>&lt;V&gt;&nbsp;V</code></div>
<div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code><a href="#getValue(org.apache.sis.util.collection.TableColumn)" class="member-name-link">get­Value</a><wbr>(<a href="TableColumn.html" title="class in org.apache.sis.util.collection">Table­Column</a>&lt;V&gt;&nbsp;column)</code></div>
<div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3">
<div class="block">Returns the value in the given column, or <code>null</code> if none.</div>
</div>
<div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code>int</code></div>
<div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code><a href="#hashCode()" class="member-name-link">hash­Code</a>()</code></div>
<div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3">
<div class="block">Returns a hash code value consistent with the <code>equals(Object)</code> implementation for this node.</div>
</div>
<div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code>boolean</code></div>
<div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code><a href="#isEditable(org.apache.sis.util.collection.TableColumn)" class="member-name-link">is­Editable</a><wbr>(<a href="TableColumn.html" title="class in org.apache.sis.util.collection">Table­Column</a>&lt;?&gt;&nbsp;column)</code></div>
<div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3">
<div class="block">Determines whether the value in the specified column is editable.</div>
</div>
<div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code>boolean</code></div>
<div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code><a href="#isLeaf()" class="member-name-link">is­Leaf</a>()</code></div>
<div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3">
<div class="block">Returns <code>true</code> if this node cannot have any children.</div>
</div>
<div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code><a href="TreeTable.Node.html" title="interface in org.apache.sis.util.collection">Tree­Table​.Node</a></code></div>
<div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code><a href="#newChild()" class="member-name-link">new­Child</a>()</code></div>
<div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3">
<div class="block">Creates a new child with the same columns than the other children, and adds it to
the <a href="#getChildren()">children collection</a>.</div>
</div>
<div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code>&lt;V&gt;&nbsp;void</code></div>
<div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code><a href="#setValue(org.apache.sis.util.collection.TableColumn,V)" class="member-name-link">set­Value</a><wbr>(<a href="TableColumn.html" title="class in org.apache.sis.util.collection">Table­Column</a>&lt;V&gt;&nbsp;column,
V&nbsp;value)</code></div>
<div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3">
<div class="block">Sets the value for the given column (optional operation).</div>
</div>
</div>
</div>
</div>
</section>
</li>
</ul>
</section>
<section class="details">
<ul class="details-list">
<!-- ============ METHOD DETAIL ========== -->
<li>
<section class="method-details" id="method-detail">
<h2>Method Details</h2>
<ul class="member-list">
<li>
<section class="detail" id="getParent()">
<h3>getParent</h3>
<div class="member-signature"><span class="return-type"><a href="TreeTable.Node.html" title="interface in org.apache.sis.util.collection">TreeTable.Node</a></span>&nbsp;<span class="element-name">getParent</span>()</div>
<div class="block">Returns the parent node, or <code>null</code> if this node is the root of the tree.
<p>There is intentionally no <code>set­Parent(Node)</code> method, as children and parent managements
are highly implementation-dependant. If the <a href="#getChildren()">children collection</a> is
modifiable, then implementations are encouraged to update automatically the parent when a child
is <em>added to</em> or <em>removed from</em> that collection.</p></div>
<dl class="notes">
<dt>Returns:</dt>
<dd>the parent, or <code>null</code> if none.</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="isLeaf()">
<h3>isLeaf</h3>
<div class="member-signature"><span class="return-type">boolean</span>&nbsp;<span class="element-name">isLeaf</span>()</div>
<div class="block">Returns <code>true</code> if this node cannot have any children. The <a href="#getChildren()">children
collection</a> of a leaf node can only be empty, and adding <a href="#newChild()">new child</a>
is an unsupported operation.
<p>This value is provided as a tip for graphical user interfaces, in order to determine if
a node is expandable (even if empty). <a href="TreeTableFormat.html" title="class in org.apache.sis.util.collection"><code>Tree­Table­Format</code></a> does not use this value.</p></div>
<dl class="notes">
<dt>Returns:</dt>
<dd><code>true</code> if this node cannot have any children.</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="getChildren()">
<h3>getChildren</h3>
<div class="member-signature"><span class="return-type"><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/Collection.html" title="class or interface in java.util" class="external-link">Collection</a>&lt;<a href="TreeTable.Node.html" title="interface in org.apache.sis.util.collection">TreeTable.Node</a>&gt;</span>&nbsp;<span class="element-name">getChildren</span>()</div>
<div class="block">Returns the children of this node. The returned collection may or may not be modifiable, at
implementation choice. If the collection is modifiable, then it shall be <em>live</em>,
i.e. any modification to the returned collection are reflected immediately in the tree.
This allows addition or removal of child nodes as below:
<div class="snippet-container"><button class="copy snippet-copy" aria-label="Copy snippet" onclick="copySnippet(this)"><span data-copied="Copied!">Copy</span><img src="../../../../../../copy.svg" alt="Copy snippet"></button>
<pre class="snippet"><code class="language-java">TreeTable.Node newNode = new ...; // Create a new node here.
parent.getChildren().add(newNode);
</code></pre>
</div>
The collection is often a <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/List.html" title="class or interface in java.util" class="external-link"><code>List</code></a>, but not necessarily. For some implementations like the
<a href="../../../../../../org.apache.sis.metadata/org/apache/sis/metadata/AbstractMetadata.html#asTreeTable()">metadata tree table view</a>,
compliance to the <code>List</code> contract is impractical or inefficient.</div>
<dl class="notes">
<dt>Returns:</dt>
<dd>the children, or an empty collection if none.</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="newChild()">
<h3>newChild</h3>
<div class="member-signature"><span class="return-type"><a href="TreeTable.Node.html" title="interface in org.apache.sis.util.collection">TreeTable.Node</a></span>&nbsp;<span class="element-name">newChild</span>()
throws <span class="exceptions"><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/UnsupportedOperationException.html" title="class or interface in java.lang" class="external-link">UnsupportedOperationException</a></span></div>
<div class="block">Creates a new child with the same columns than the other children, and adds it to
the <a href="#getChildren()">children collection</a>. The new child is typically added at
the end of the collection, but this is not mandatory: implementations can add the child
at whatever position they see fit.</div>
<dl class="notes">
<dt>Returns:</dt>
<dd>the new child.</dd>
<dt>Throws:</dt>
<dd><code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/UnsupportedOperationException.html" title="class or interface in java.lang" class="external-link">Unsupported­Operation­Exception</a></code> - if this node cannot add new children.</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="getValue(org.apache.sis.util.collection.TableColumn)">
<h3>getValue</h3>
<div class="member-signature"><span class="type-parameters">&lt;V&gt;</span>&nbsp;<span class="return-type">V</span>&nbsp;<span class="element-name">getValue</span><wbr><span class="parameters">(<a href="TableColumn.html" title="class in org.apache.sis.util.collection">TableColumn</a>&lt;V&gt;&nbsp;column)</span></div>
<div class="block">Returns the value in the given column, or <code>null</code> if none.</div>
<dl class="notes">
<dt>Type Parameters:</dt>
<dd><code>V</code> - the base type of values in the given column.</dd>
<dt>Parameters:</dt>
<dd><code>column</code> - identifier of the column from which to get the value.</dd>
<dt>Returns:</dt>
<dd>the value in the given column, or <code>null</code> if none.</dd>
<dt>See Also:</dt>
<dd>
<ul class="tag-list">
<li><a href="TreeTable.html#getColumns()"><code>Tree­Table​.get­Columns()</code></a></li>
</ul>
</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="setValue(org.apache.sis.util.collection.TableColumn,V)">
<h3 id="setValue(org.apache.sis.util.collection.TableColumn,java.lang.Object)">setValue</h3>
<div class="member-signature"><span class="type-parameters">&lt;V&gt;</span>&nbsp;<span class="return-type">void</span>&nbsp;<span class="element-name">setValue</span><wbr><span class="parameters">(<a href="TableColumn.html" title="class in org.apache.sis.util.collection">TableColumn</a>&lt;V&gt;&nbsp;column,
V&nbsp;value)</span>
throws <span class="exceptions"><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/IllegalArgumentException.html" title="class or interface in java.lang" class="external-link">IllegalArgumentException</a>,
<a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/UnsupportedOperationException.html" title="class or interface in java.lang" class="external-link">UnsupportedOperationException</a></span></div>
<div class="block">Sets the value for the given column (optional operation).
The <a href="#isEditable(org.apache.sis.util.collection.TableColumn)"><code>is­Editable(Table­Column)</code></a> method can be invoked before this setter method
for determining if the given column is modifiable.</div>
<dl class="notes">
<dt>Type Parameters:</dt>
<dd><code>V</code> - the base type of values in the given column.</dd>
<dt>Parameters:</dt>
<dd><code>column</code> - identifier of the column into which to set the value.</dd>
<dd><code>value</code> - the value to set.</dd>
<dt>Throws:</dt>
<dd><code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/IllegalArgumentException.html" title="class or interface in java.lang" class="external-link">Illegal­Argument­Exception</a></code> - if the given column is not a legal column for this node.</dd>
<dd><code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/UnsupportedOperationException.html" title="class or interface in java.lang" class="external-link">Unsupported­Operation­Exception</a></code> - if values in the given column cannot be modified.</dd>
<dt>See Also:</dt>
<dd>
<ul class="tag-list">
<li><a href="TreeTable.html#getColumns()"><code>Tree­Table​.get­Columns()</code></a></li>
<li><a href="#isEditable(org.apache.sis.util.collection.TableColumn)"><code>is­Editable(Table­Column)</code></a></li>
</ul>
</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="isEditable(org.apache.sis.util.collection.TableColumn)">
<h3>isEditable</h3>
<div class="member-signature"><span class="return-type">boolean</span>&nbsp;<span class="element-name">isEditable</span><wbr><span class="parameters">(<a href="TableColumn.html" title="class in org.apache.sis.util.collection">TableColumn</a>&lt;?&gt;&nbsp;column)</span></div>
<div class="block">Determines whether the value in the specified column is editable. If the given
column is not a legal column for this <code>Node</code> instance, then this method
returns <code>false</code>.</div>
<dl class="notes">
<dt>Parameters:</dt>
<dd><code>column</code> - the column to query.</dd>
<dt>Returns:</dt>
<dd><code>true</code> if the given column is a legal column for this <code>Node</code>
implementation and the corresponding value is editable, or <code>false</code>
otherwise.</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="getUserObject()">
<h3>getUserObject</h3>
<div class="member-signature"><span class="return-type"><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Object.html" title="class or interface in java.lang" class="external-link">Object</a></span>&nbsp;<span class="element-name">getUserObject</span>()</div>
<div class="block">Returns the user object associated to this node.
The user object is for information purpose only and does not appear in the rendered tree.
It is typically a Java object whose content is splitted into the various table columns.
<h4 id="example-heading">Example</h4>
If a <code>City­Location</code> class is defined as a (<var>city name</var>, <var>latitude</var>,
<var>longitude</var>) tuple, then a <code>Tree­Table​.Node</code> could be defined to have 3 columns for the
above 3 tuple components, and the user object could be the original <code>City­Location</code> instance.</div>
<dl class="notes">
<dt>Returns:</dt>
<dd>any object stored at this node by the user, or <code>null</code> if none.</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="equals(java.lang.Object)">
<h3>equals</h3>
<div class="member-signature"><span class="return-type">boolean</span>&nbsp;<span class="element-name">equals</span><wbr><span class="parameters">(<a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Object.html" title="class or interface in java.lang" class="external-link">Object</a>&nbsp;other)</span></div>
<div class="block">Returns <code>true</code> if the given object is a node with the same content than this node.
For this method, the meaning of <cite>same content</cite> is defined as below:
<ul>
<li>The given object is also a <code>Node</code>.</li>
<li>The list returned by <a href="TreeTable.html#getColumns()"><code>Tree­Table​.get­Columns()</code></a> is equal for both nodes.</li>
<li>The objects returned by <a href="#getValue(org.apache.sis.util.collection.TableColumn)"><code>get­Value(Table­Column)</code></a> are equal for each column.</li>
<li>The list returned by <a href="#getChildren()">children</a> is equal for both node.</li>
</ul>
The node returned by <a href="#getParent()"><code>get­Parent()</code></a> shall <strong>not</strong> be taken in account.
It is necessary to ignore the parent for consistency with <a href="DefaultTreeTable.html#clone()">clone</a>
and for avoiding infinite recursivity when comparing the children.
A third reason is given in the <cite>purpose</cite> example below.
<h4 id="purpose-of-this-method-example-with-iso-metadata-heading">Purpose of this method: example with ISO metadata</h4>
Consider the following tree made of ISO 19115 metadata objects: a platform containing a list of instruments,
and an instrument containing a reference to the platform on which the instrument is installed. In this example,
nodes 2 and 4 contain a reference to the same <code>Platform</code> instance, so we have a cyclic graph:
<table class="compact">
<caption>Metadata tree example</caption>
<tr><th>Node 1:</th><td><code> </code><a href="../../../../../../org.apache.sis.metadata/org/apache/sis/metadata/iso/acquisition/DefaultAcquisitionInformation.html" title="class in org.apache.sis.metadata.iso.acquisition">Acquisition information</a></td></tr>
<tr><th>Node 2:</th><td><code>  └─</code><a href="../../../../../../org.apache.sis.metadata/org/apache/sis/metadata/iso/acquisition/DefaultPlatform.html" title="class in org.apache.sis.metadata.iso.acquisition">Platform</a></td></tr>
<tr><th>Node 3:</th><td><code>     └─</code><a href="../../../../../../org.apache.sis.metadata/org/apache/sis/metadata/iso/acquisition/DefaultInstrument.html" title="class in org.apache.sis.metadata.iso.acquisition">Instrument</a></td></tr>
<tr><th>Node 4:</th><td><code>        └─</code><a href="../../../../../../org.apache.sis.metadata/org/apache/sis/metadata/iso/acquisition/DefaultPlatform.html" title="class in org.apache.sis.metadata.iso.acquisition">Platform</a> (same instance than above)</td></tr>
<tr><th>Node 5:</th><td><code>           └─</code><i>etc…</i></td></tr>
</table>
The <a href="../../../../../../org.apache.sis.metadata/org/apache/sis/metadata/AbstractMetadata.html#asTreeTable()"><code>Abstract­Metadata​.as­Tree­Table()</code></a> method gives a view in which each node
has its content fully generated from wrapped metadata object. Consequently, a naive walk over the above tree
causes an infinite loop with <code>Tree­Table</code> generating nodes with identical content as we bounce between
<code>Platform</code> and <code>Instrument</code> metadata objects. To break this loop, we need to know when the
<em>content</em> of a node (in this example, the wrapped metadata object) has already been visited.
The parent shall <strong>not</strong> be taken in account since node 2 and 4 have different parents
despite having the same <code>Platform</code> content.
<p>In this use case, the <code>Node​.equals(Object)</code> implementation needs only to compare the wrapped
metadata (usually given by the <a href="#getUserObject()">user object</a>) since the node content,
including the list of children, is fully determined by those metadata. An identity comparison
(with <code>==</code>) is sufficient for the purpose of avoiding infinite recursivity.</p>
<h4 id="flexibility-in-implementations-heading">Flexibility in implementations</h4>
The above list specifies minimal conditions that must be true when two nodes are considered equal.
Implementations should not relax those conditions, but are free to make them more restrictive.
In particular, many implementations will require that the two nodes are instances of the same class.
Some implementations may also perform identity comparisons (with the <code>==</code> operator) between values
instead of using <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Object.html#equals(java.lang.Object)" title="class or interface in java.lang" class="external-link"><code>Object​.equals(Object)</code></a>. This flexibility means that even if all above conditions
are true, this is not a guarantee that this method will return <code>true</code>.
<p>It is okay to <em>not</em> override this method at all since the identity comparison inherited from
<a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Object.html#equals(java.lang.Object)" title="class or interface in java.lang" class="external-link"><code>Object​.equals(Object)</code></a> is consistent with this method contract. Alternatively, <code>Node</code>
implementations having a content fully determined by the wrapped <a href="#getUserObject()">user
object</a> need only the following implementation:</p>
<div class="snippet-container"><button class="copy snippet-copy" aria-label="Copy snippet" onclick="copySnippet(this)"><span data-copied="Copied!">Copy</span><img src="../../../../../../copy.svg" alt="Copy snippet"></button>
<pre class="snippet"><code class="language-java"> @Override
public boolean equals(Object obj) {
return (obj instanceof MyNode) &amp;&amp; ((MyNode) obj).getUserObject() == getUserObject();
}
</code></pre>
</div>
Implementation details may vary, for example in the way to compare <code>null</code> user objects or by invoking
<a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Object.html#equals(java.lang.Object)" title="class or interface in java.lang" class="external-link"><code>Object​.equals(Object)</code></a> instead of performing identity comparisons. Note however that since this
method purpose is to detect cyclic graphs (see above example), user objects should be compared with
<code>equals(Object)</code> only if their implementations are known to be safe against infinite recursivity.</div>
<dl class="notes">
<dt>Overrides:</dt>
<dd><code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Object.html#equals(java.lang.Object)" title="class or interface in java.lang" class="external-link">equals</a></code>&nbsp;in class&nbsp;<code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Object.html" title="class or interface in java.lang" class="external-link">Object</a></code></dd>
<dt>Parameters:</dt>
<dd><code>other</code> - the other object to compare with this node.</dd>
<dt>Returns:</dt>
<dd>whether the two objects are nodes with equal values and equal children, ignoring parents.</dd>
<dt>Since:</dt>
<dd>0.8</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="hashCode()">
<h3>hashCode</h3>
<div class="member-signature"><span class="return-type">int</span>&nbsp;<span class="element-name">hashCode</span>()</div>
<div class="block">Returns a hash code value consistent with the <code>equals(Object)</code> implementation for this node.
If the <a href="#equals(java.lang.Object)"><code>equals(Object)</code></a> method has not been overridden, then this <code>hash­Code()</code> method
should not be overridden neither. Otherwise if this node content (<a href="#getValue(org.apache.sis.util.collection.TableColumn)">values</a> and
<a href="#getChildren()">children</a>) is fully generated from the <a href="#getUserObject()">user
object</a>, then the <code>equals(…)</code> and <code>hash­Code()</code> methods may be implemented like below:
<div class="snippet-container"><button class="copy snippet-copy" aria-label="Copy snippet" onclick="copySnippet(this)"><span data-copied="Copied!">Copy</span><img src="../../../../../../copy.svg" alt="Copy snippet"></button>
<pre class="snippet"><code class="language-java"> @Override
public boolean equals(Object obj) {
return (obj instanceof MyNode) &amp;&amp; ((MyNode) obj).getUserObject() == getUserObject();
}
@Override
public int hashCode() {
return System.identityHashCode(getUserObject());
}
</code></pre>
</div>
Otherwise this method should compute a hash code based on values and children of this node, ignoring parent.</div>
<dl class="notes">
<dt>Overrides:</dt>
<dd><code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Object.html#hashCode()" title="class or interface in java.lang" class="external-link">hash­Code</a></code>&nbsp;in class&nbsp;<code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Object.html" title="class or interface in java.lang" class="external-link">Object</a></code></dd>
<dt>Returns:</dt>
<dd>a hash code for this node, potentially based on values and children but ignoring parent.</dd>
<dt>Since:</dt>
<dd>0.8</dd>
</dl>
</section>
</li>
</ul>
</section>
</li>
</ul>
</section>
<!-- ========= END OF CLASS DATA ========= -->
</main>
</div>
</div>
</body>
</html>