diff --git a/pom.xml b/pom.xml
index 47e6274..01cc354 100644
--- a/pom.xml
+++ b/pom.xml
@@ -31,12 +31,6 @@
2016
-
- org.projectlombok
- lombok
- 1.16.6
-
-
junit
junit
diff --git a/src/main/java/net/kemitix/node/NodeItem.java b/src/main/java/net/kemitix/node/NodeItem.java
index 2a6b4ba..0751a3e 100644
--- a/src/main/java/net/kemitix/node/NodeItem.java
+++ b/src/main/java/net/kemitix/node/NodeItem.java
@@ -1,8 +1,5 @@
package net.kemitix.node;
-import lombok.Getter;
-import lombok.NonNull;
-
import java.util.HashSet;
import java.util.List;
import java.util.Optional;
@@ -17,13 +14,10 @@ import java.util.Set;
*/
public class NodeItem implements Node {
- @Getter
private final T data;
- @Getter
private Node parent;
- @Getter
private Set> children;
/**
@@ -31,7 +25,7 @@ public class NodeItem implements Node {
*
* @param data the value of the node
*/
- public NodeItem(@NonNull final T data) {
+ public NodeItem(final T data) {
this(data, null);
}
@@ -42,6 +36,9 @@ public class NodeItem implements Node {
* @param parent the parent node
*/
public NodeItem(final T data, final Node parent) {
+ if (data == null) {
+ throw new NullPointerException("data");
+ }
this.data = data;
if (parent != null) {
setParent(parent);
@@ -49,13 +46,31 @@ public class NodeItem implements Node {
this.children = new HashSet<>();
}
+ @Override
+ public T getData() {
+ return data;
+ }
+
+ @Override
+ public Node getParent() {
+ return parent;
+ }
+
+ @Override
+ public Set> getChildren() {
+ return children;
+ }
+
/**
* Make the current node a direct child of the parent.
*
* @param parent the new parent node
*/
@Override
- public final void setParent(@NonNull final Node parent) {
+ public final void setParent(final Node parent) {
+ if (parent == null) {
+ throw new NullPointerException("parent");
+ }
if (this.equals(parent) || parent.isChildOf(this)) {
throw new NodeException("Parent is a descendant");
}
@@ -72,7 +87,10 @@ public class NodeItem implements Node {
* @param child the node to add
*/
@Override
- public void addChild(@NonNull final Node child) {
+ public void addChild(final Node child) {
+ if (child == null) {
+ throw new NullPointerException("child");
+ }
if (this.equals(child) || isChildOf(child)) {
throw new NodeException("Child is an ancestor");
}
@@ -104,11 +122,13 @@ public class NodeItem implements Node {
* Walks the node tree using the path to select each child.
*
* @param path the path to the desired child
- *
* @return the child or null
*/
@Override
- public Optional> walkTree(@NonNull final List path) {
+ public Optional> walkTree(final List path) {
+ if (path == null) {
+ throw new NullPointerException("path");
+ }
if (path.size() > 0) {
Optional> found = getChild(path.get(0));
if (found.isPresent()) {
@@ -128,7 +148,10 @@ public class NodeItem implements Node {
* @param descendants the line of descendants from the current node
*/
@Override
- public void createDescendantLine(@NonNull final List descendants) {
+ public void createDescendantLine(final List descendants) {
+ if (descendants == null) {
+ throw new NullPointerException("descendants");
+ }
if (!descendants.isEmpty()) {
findOrCreateChild(descendants.get(0))
.createDescendantLine(
@@ -145,7 +168,10 @@ public class NodeItem implements Node {
* @return the found or created child node
*/
@Override
- public Node findOrCreateChild(@NonNull final T child) {
+ public Node findOrCreateChild(final T child) {
+ if (child == null) {
+ throw new NullPointerException("child");
+ }
Optional> found = getChild(child);
if (found.isPresent()) {
return found.get();
@@ -162,7 +188,10 @@ public class NodeItem implements Node {
* @return an {@link Optional} containing the child node if found
*/
@Override
- public Optional> getChild(@NonNull final T child) {
+ public Optional> getChild(final T child) {
+ if (child == null) {
+ throw new NullPointerException("child");
+ }
return children.stream()
.filter((Node t) -> t.getData().equals(child))
.findAny();
@@ -176,7 +205,10 @@ public class NodeItem implements Node {
* @return the new child node
*/
@Override
- public Node createChild(@NonNull final T child) {
+ public Node createChild(final T child) {
+ if (child == null) {
+ throw new NullPointerException("child");
+ }
return new NodeItem<>(child, this);
}