/** * Returns all {@link RoadUser}s that are on the connection between * <code>from</code> and <code>to</code> (inclusive). * @param from The start point of a connection. * @param to The end point of a connection. * @return The {@link RoadUser}s that are on the connection, or an empty set * in case {@link #hasRoadUserOn(Point, Point)} returns * <code>false</code>. * @throws IllegalArgumentException if no connection exists between * <code>from</code> and <code>to</code>. */ @Override public ImmutableSet<RoadUser> getRoadUsersOn(Point from, Point to) { checkConnectionsExists(from, to); final Connection<?> conn = graph.getConnection(from, to); return ImmutableSet.<RoadUser>builder() .addAll(registry().getObjectsOn(conn)) .addAll(registry().getObjectsOn(from)) .addAll(registry().getObjectsOn(to)) .build(); }
/** * Checks whether there is a {@link RoadUser} on the connection between * <code>from</code> and <code>to</code> (inclusive). * @param from The start point of a connection. * @param to The end point of a connection. * @return <code>true</code> if a {@link RoadUser} occupies either * <code>from</code>, <code>to</code> or the connection between * <code>from</code> and <code>to</code>, <code>false</code> * otherwise. * @throws IllegalArgumentException if no connection exists between * <code>from</code> and <code>to</code>. */ @Override public boolean hasRoadUserOn(Point from, Point to) { checkConnectionsExists(from, to); return registry().hasObjectOn(graph.getConnection(from, to)) || registry().hasObjectOn(from) || registry().hasObjectOn(to); }