private String determineReturnNodeName(RouteNode node, MovePoint movePoint, int currentStep) throws InvalidActionTakenException { if (currentStep == movePoint.getStepsToMove()) { return node.getRouteNodeName(); } List previousNodes = node.getPreviousNodes(); if (previousNodes.size() == 0) { throw new InvalidActionTakenException( "Could not locate the named target node in the document's past route. Halted on step " + currentStep); } if (previousNodes.size() != 1) { throw new InvalidActionTakenException( "Located a multi-branch path, could not proceed backward past this point. Halted on step " + currentStep); } return determineReturnNodeName((RouteNode) previousNodes.get(0), movePoint, currentStep - 1); }
public void addNextNode(RouteNode nextNode) { getNextNodes().add(nextNode); nextNode.getPreviousNodes().add(this); }