* @return <code>true</code> if the given node is a direct child of this
* node, <code>false</code> otherwise
*/
- public boolean hasChildNode(Node<E> childNode);
+ public boolean hasChild(Node<E> childNode);
+
+ /**
+ * Returns whether this node contains a child node containing the given
+ * element.
+ *
+ * @param element
+ * The element
+ * @return <code>true</code> if this node contains a direct child node
+ * containing the given element, <code>false</code> otherwise
+ */
+ public boolean hasChild(E element);
/**
* Returns the index of the given child node.
/**
* {@inheritDoc}
*/
- public boolean hasChildNode(Node<E> childNode) {
+ public boolean hasChild(Node<E> childNode) {
return children.contains(childNode);
}
/**
* {@inheritDoc}
*/
+ public boolean hasChild(E element) {
+ for (Node<E> childNode: children) {
+ if (childNode.getElement().equals(element)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public int getIndexOfChild(Node<E> childNode) {
int childIndex = 0;
for (Node<E> node: children) {