From: David ‘Bombe’ Roden Date: Mon, 26 May 2008 19:39:28 +0000 (+0200) Subject: rename hasChildNode to hasChild X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=593994cd718f3636d14e11686e0e66c0512f6516;p=jSite2.git rename hasChildNode to hasChild add second hasChild method --- 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) {