Class Route
- java.lang.Object
-
- org.opentrafficsim.core.network.route.Route
-
- All Implemented Interfaces:
Serializable,Identifiable
- Direct Known Subclasses:
CompleteRoute
public class Route extends Object implements Serializable, Identifiable
A Route consists of a list of Nodes. A route does not have to be complete. As long as all 'splitting' nodes are part of the route and have a valid successor node (connected by a Link), the strategical planner is able to make a plan. An extension of the Route class exists that contains a complete route, where all nodes on the route have to be present and connected.Copyright (c) 2013-2020 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
$LastChangedDate: 2020-05-14 13:12:03 +0200 (Thu, 14 May 2020) $, @version $Revision: 6470 $, by $Author: pknoppers $, initial version Jan 1, 2015
BSD-style license. See OpenTrafficSim License.- Author:
- Alexander Verbraeck, Peter Knoppers
- See Also:
- Serialized Form
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description RouteaddNode(Node node)Add a node to the end of the node list of this Route.Routeclone(Network newNetwork)Clone this Route.booleancontains(Node node)Indicate if this Route contains a specific Node.NodedestinationNode()Retrieve the last Node of this Route.booleanequals(Object obj)StringgetId()Retrieve the name of this Route.NodegetNode(int i)Retrieve one Node of this Route.List<Node>getNodes()Retrieve the Node List of this Route.inthashCode()intindexOf(Node node)Return the index of a Node in this Route, or -1 if this Route does not contain the specified Node.NodeoriginNode()Retrieve the origin node of this Route.intsize()StringtoString()voidverify()Verify that there are normal (non Connectors) between adjacent nodes, except at start and end (where Connectors are OK).
-
-
-
Constructor Detail
-
Route
public Route(String id)
Create an empty route.- Parameters:
id- String; the name of the route.
-
-
Method Detail
-
verify
public void verify()
Verify that there are normal (non Connectors) between adjacent nodes, except at start and end (where Connectors are OK).
-
addNode
public Route addNode(Node node) throws NetworkException
Add a node to the end of the node list of this Route.- Parameters:
node- Node; the node to add- Returns:
- Route; this route for method chaining
- Throws:
NetworkException- in case node could not be added to the route
-
getNodes
public final List<Node> getNodes()
Retrieve the Node List of this Route. DO NOT MODIFY.- Returns:
- List<Node>; the Node List
-
getNode
public final Node getNode(int i) throws NetworkException
Retrieve one Node of this Route.- Parameters:
i- int; the index of the node to retrieve- Returns:
- Node; the node at index i.
- Throws:
NetworkException- if i < 0 or i > size
-
originNode
public final Node originNode() throws NetworkException
Retrieve the origin node of this Route.- Returns:
- Node; the first node of the route
- Throws:
NetworkException- when this Route has no nodes
-
size
public final int size()
- Returns:
- the number of nodes in the list. If the list contains more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE.
-
destinationNode
public final Node destinationNode() throws NetworkException
Retrieve the last Node of this Route.- Returns:
- Node; the last Node of the Route
- Throws:
NetworkException- when Route has has no nodes
-
indexOf
public final int indexOf(Node node)
Return the index of a Node in this Route, or -1 if this Route does not contain the specified Node.
If this Route contains the Node more than once, the index of the first is returned.- Parameters:
node- Node; the Node to find- Returns:
- int;
-
contains
public final boolean contains(Node node)
Indicate if this Route contains a specific Node.- Parameters:
node- Node; the Node to find- Returns:
- boolean; true if this Route contains the specified node; false if this Route does not contain the specified Node
-
getId
public final String getId()
Retrieve the name of this Route.- Specified by:
getIdin interfaceIdentifiable- Returns:
- String; the name of this Route
-
clone
public Route clone(Network newNetwork) throws NetworkException
Clone this Route.- Parameters:
newNetwork- Network; the new network- Returns:
- a clone of this route
- Throws:
NetworkException- in case the cloning fails
-
-