X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fnet%2Fpterodactylus%2Futil%2Fdata%2FNodeImpl.java;h=2d578766a5f5929c7dbed5827e6398aa92467e04;hb=364659907c0364092e78824d3eea4a13fecd831b;hp=a30f76ea254c562855ba027e93ead0a763b52a6e;hpb=415d6680a02bfbd85ad3f154a7c7f2aee5453549;p=jSite2.git diff --git a/src/net/pterodactylus/util/data/NodeImpl.java b/src/net/pterodactylus/util/data/NodeImpl.java index a30f76e..2d57876 100644 --- a/src/net/pterodactylus/util/data/NodeImpl.java +++ b/src/net/pterodactylus/util/data/NodeImpl.java @@ -87,6 +87,41 @@ class NodeImpl implements Node { /** * {@inheritDoc} */ + public boolean hasChildNode(Node childNode) { + return children.contains(childNode); + } + + /** + * {@inheritDoc} + */ + public int getIndexOfChild(Node childNode) { + int childIndex = 0; + for (Node node: children) { + if (node.equals(childNode)) { + return childIndex; + } + childIndex++; + } + return -1; + } + + /** + * {@inheritDoc} + */ + public int getIndexOfChild(E element) { + int childIndex = 0; + for (Node node: children) { + if (node.getElement().equals(element)) { + return childIndex; + } + childIndex++; + } + return -1; + } + + /** + * {@inheritDoc} + */ public void removeChild(Node childNode) { children.remove(childNode); } @@ -117,4 +152,20 @@ class NodeImpl implements Node { return children.iterator(); } + /** + * {@inheritDoc} + */ + public Node findChild(E element) { + for (Node childNode: children) { + Node wantedNode = childNode.findChild(element); + if (wantedNode != null) { + return wantedNode; + } + } + if (this.element.equals(element)) { + return this; + } + return null; + } + } \ No newline at end of file