Node: may be empty, having no data

* isEmpty()
This commit is contained in:
Paul Campbell 2016-05-24 09:57:11 +01:00
parent 921cf98b13
commit 36efe5d83a
2 changed files with 12 additions and 0 deletions

View file

@ -20,6 +20,13 @@ public interface Node<T> {
*/
T getData();
/**
* Returns true if the node is empty (has no data).
*
* @return true is data is null
*/
boolean isEmpty();
/**
* Fetch the parent node.
* <p>

View file

@ -50,6 +50,11 @@ public class NodeItem<T> implements Node<T> {
return data;
}
@Override
public boolean isEmpty() {
return data == null;
}
@Override
public Node<T> getParent() {
return parent;