add getChild(E)
[jSite2.git] / src / net / pterodactylus / util / data / NodeImpl.java
index 2d57876..785fa1f 100644 (file)
@@ -87,13 +87,37 @@ class NodeImpl<E> implements Node<E> {
        /**
         * {@inheritDoc}
         */
-       public boolean hasChildNode(Node<E> childNode) {
+       public Node<E> getChild(E element) {
+               for (Node<E> childNode: children) {
+                       if (childNode.getElement().equals(element)) {
+                               return childNode;
+                       }
+               }
+               return null;
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       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) {
@@ -148,6 +172,13 @@ class NodeImpl<E> implements Node<E> {
        /**
         * {@inheritDoc}
         */
+       public void removeAllChildren() {
+               children.clear();
+       }
+
+       /**
+        * {@inheritDoc}
+        */
        public Iterator<Node<E>> iterator() {
                return children.iterator();
        }