From b2130442e50a67f7bd58e8e7b8c702ad58acb713 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Mon, 22 Aug 2016 08:52:42 +0100 Subject: [PATCH] AbstractNodeItem: replace manual null checks with @NonNull --- .../java/net/kemitix/node/AbstractNodeItem.java | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/src/main/java/net/kemitix/node/AbstractNodeItem.java b/src/main/java/net/kemitix/node/AbstractNodeItem.java index 6aa90e7..4815d93 100644 --- a/src/main/java/net/kemitix/node/AbstractNodeItem.java +++ b/src/main/java/net/kemitix/node/AbstractNodeItem.java @@ -1,5 +1,7 @@ package net.kemitix.node; +import lombok.NonNull; + import java.util.HashSet; import java.util.List; import java.util.Optional; @@ -65,10 +67,7 @@ abstract class AbstractNodeItem implements Node { * @return an {@link Optional} containing the child node if found */ @Override - public Optional> findChild(final T child) { - if (child == null) { - throw new NullPointerException("child"); - } + public Optional> findChild(@NonNull final T child) { return children.stream().filter(node -> { final Optional d = node.getData(); return d.isPresent() && d.get().equals(child); @@ -102,10 +101,7 @@ abstract class AbstractNodeItem implements Node { * @return the child or null */ @Override - public Optional> findInPath(final List path) { - if (path == null) { - throw new NullPointerException("path"); - } + public Optional> findInPath(@NonNull final List path) { if (path.size() > 0) { Optional> found = findChild(path.get(0)); if (found.isPresent()) { @@ -119,10 +115,7 @@ abstract class AbstractNodeItem implements Node { } @Override - public Optional> findChildByName(final String named) { - if (named == null) { - throw new NullPointerException("name"); - } + public Optional> findChildByName(@NonNull final String named) { return children.stream() .filter(n -> n.getName().equals(named)) .findAny();