Skip to content

Commit

Permalink
Fixing the NPE.
Browse files Browse the repository at this point in the history
  • Loading branch information
mansoor-sajjad committed Oct 19, 2024
1 parent 2ffffc9 commit 4691cf8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
7 changes: 7 additions & 0 deletions src/main/java/no/entur/antu/validation/AntuNetexData.java
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,13 @@ public Map.Entry<ScheduledStopPointId, QuayCoordinates> coordinatesPerQuayId(
: Map.entry(scheduledStopPointId, coordinatesForQuayId);
}

public QuayCoordinates coordinatesForScheduledStopPoint(
ScheduledStopPointId scheduledStopPointId
) {
QuayId quayId = quayIdForScheduledStopPoint(scheduledStopPointId);
return quayId == null ? null : coordinatesForQuayId(quayId);
}

public String stopPointName(ScheduledStopPointId scheduledStopPointId) {
QuayId quayId = quayIdForScheduledStopPoint(scheduledStopPointId);
if (quayId == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ public static UnexpectedInterchangeDistanceContext of(
scheduledStopPointId ->
new ScheduledStopPointCoordinates(
scheduledStopPointId,
antuNetexData.coordinatesForQuayId(
antuNetexData.quayIdForScheduledStopPoint(scheduledStopPointId)
)
antuNetexData.coordinatesForScheduledStopPoint(scheduledStopPointId)
);

return new UnexpectedInterchangeDistanceContext(
Expand All @@ -36,6 +34,7 @@ public static UnexpectedInterchangeDistanceContext of(
)
)
.map(scheduledStopPointCoordinates)
.filter(ScheduledStopPointCoordinates::isValid)
.orElse(null),
Optional
.ofNullable(
Expand All @@ -44,6 +43,7 @@ public static UnexpectedInterchangeDistanceContext of(
)
)
.map(scheduledStopPointCoordinates)
.filter(ScheduledStopPointCoordinates::isValid)
.orElse(null)
);
}
Expand Down

0 comments on commit 4691cf8

Please sign in to comment.