File tree Expand file tree Collapse file tree
core/src/main/java/com/github/rinde/rinsim/core/model/road Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -474,10 +474,7 @@ public Graph<? extends ConnectionData> getGraph() {
474474 */
475475 @ Override
476476 public Optional <? extends Connection <?>> getConnection (RoadUser obj ) {
477- if (registry ().isOnConnection (obj )) {
478- return Optional .of (registry .getConnection (obj ));
479- }
480- return Optional .absent ();
477+ return registry .getOptionalConnection (obj );
481478 }
482479
483480 @ Override
Original file line number Diff line number Diff line change 2525import com .github .rinde .rinsim .geom .Connection ;
2626import com .github .rinde .rinsim .geom .Point ;
2727import com .google .auto .value .AutoValue ;
28+ import com .google .common .base .Optional ;
2829import com .google .common .collect .LinkedHashMultimap ;
2930import com .google .common .collect .SetMultimap ;
3031
@@ -133,6 +134,14 @@ public Connection<?> getConnection(T ru) {
133134 return connLocMap .get (ru ).connection ();
134135 }
135136
137+ public Optional <? extends Connection <?>> getOptionalConnection (T ru ) {
138+ final ConnLoc cl = connLocMap .get (ru );
139+ if (cl == null ) {
140+ return Optional .absent ();
141+ }
142+ return Optional .of (cl .connection ());
143+ }
144+
136145 public double getRelativePosition (Point p ) {
137146 if (!posMap .containsKey (p )) {
138147 return 0d ;
You can’t perform that action at this time.
0 commit comments