From 36efe5d83ab5e3f63c6cf3cd208b54a19c1600ce Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Tue, 24 May 2016 09:57:11 +0100 Subject: [PATCH] Node: may be empty, having no data * isEmpty() --- src/main/java/net/kemitix/node/Node.java | 7 +++++++ src/main/java/net/kemitix/node/NodeItem.java | 5 +++++ 2 files changed, 12 insertions(+) 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;