From 593994cd718f3636d14e11686e0e66c0512f6516 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Mon, 26 May 2008 21:39:28 +0200 Subject: [PATCH] rename hasChildNode to hasChild add second hasChild method --- src/net/pterodactylus/util/data/Node.java | 13 ++++++++++++- src/net/pterodactylus/util/data/NodeImpl.java | 14 +++++++++++++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/net/pterodactylus/util/data/Node.java b/src/net/pterodactylus/util/data/Node.java index 37588b5..2f6ec74 100644 --- a/src/net/pterodactylus/util/data/Node.java +++ b/src/net/pterodactylus/util/data/Node.java @@ -61,7 +61,18 @@ public interface Node extends Iterable> { * @return true if the given node is a direct child of this * node, false otherwise */ - public boolean hasChildNode(Node childNode); + public boolean hasChild(Node childNode); + + /** + * Returns whether this node contains a child node containing the given + * element. + * + * @param element + * The element + * @return true if this node contains a direct child node + * containing the given element, false otherwise + */ + public boolean hasChild(E element); /** * Returns the index of the given child node. diff --git a/src/net/pterodactylus/util/data/NodeImpl.java b/src/net/pterodactylus/util/data/NodeImpl.java index 283a663..5c04aee 100644 --- a/src/net/pterodactylus/util/data/NodeImpl.java +++ b/src/net/pterodactylus/util/data/NodeImpl.java @@ -87,13 +87,25 @@ class NodeImpl implements Node { /** * {@inheritDoc} */ - public boolean hasChildNode(Node childNode) { + public boolean hasChild(Node childNode) { return children.contains(childNode); } /** * {@inheritDoc} */ + public boolean hasChild(E element) { + for (Node childNode: children) { + if (childNode.getElement().equals(element)) { + return true; + } + } + return false; + } + + /** + * {@inheritDoc} + */ public int getIndexOfChild(Node childNode) { int childIndex = 0; for (Node node: children) { -- 2.7.4