Xtend Recursive method issues [message #1080649] |
Tue, 06 August 2013 04:02  |
Eclipse User |
|
|
|
Hi,
I have a java class with two methods like :
public List<Node> collectSubNodes(Node node)
{
List<Node> nodeList = new ArrayList<Node>();
collectSubStatesOfState(node, nodeList );
return nodeList ;
}
private void collectSubNodesOfNode(Node node, List<Node> nodeList )
{
if(node!= null)
{
EList<Vertex> subnodes = node.getSubNodes();
for(Vertex vertex : subnodes )
{
if(vertex instanceof Node )
{
Node subNode = (Node )vertex;
nodeList.add(subNode );
collectSubNodesOfNode(subNode, nodeList);
}
}
}
}
I want to write this in an *.ext class, i tried with
cached List[Node ] collectSubNodes(Node this) :
subNodes.typeSelect(Node).addAll(subNodes.typeSelect(Node).collectSubNodes())
;
but i am getting StackOverflow exception, May be it is going in infinite loop.
but i am struggling to write as it is recursive method and should return a list with all the details. Please help me in writing the same.
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.24687 seconds