diff --git a/src/main/java/net/kemitix/node/Node.java b/src/main/java/net/kemitix/node/Node.java index 002bead..2d9c67e 100644 --- a/src/main/java/net/kemitix/node/Node.java +++ b/src/main/java/net/kemitix/node/Node.java @@ -20,6 +20,13 @@ public interface Node { */ T getData(); + /** + * Returns true if the node is empty (has no data). + * + * @return true is data is null + */ + boolean isEmpty(); + /** * Fetch the parent node. *

diff --git a/src/main/java/net/kemitix/node/NodeItem.java b/src/main/java/net/kemitix/node/NodeItem.java index d11ff23..c3a3b45 100644 --- a/src/main/java/net/kemitix/node/NodeItem.java +++ b/src/main/java/net/kemitix/node/NodeItem.java @@ -50,6 +50,11 @@ public class NodeItem implements Node { return data; } + @Override + public boolean isEmpty() { + return data == null; + } + @Override public Node getParent() { return parent;