Skip to content

Commit

Permalink
Use cast to extract code
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardehrenfried committed May 31, 2024
1 parent 78cd79b commit ab5ec25
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@
import java.util.Objects;
import java.util.Optional;
import java.util.stream.Collectors;
import javax.annotation.Nullable;
import org.opentripplanner.framework.collection.ListUtils;
import org.opentripplanner.framework.geometry.WgsCoordinate;
import org.opentripplanner.framework.i18n.I18NString;
import org.opentripplanner.model.FeedInfo;
import org.opentripplanner.transit.model.framework.FeedScopedId;
import org.opentripplanner.transit.model.network.Route;
import org.opentripplanner.transit.model.organization.Agency;
import org.opentripplanner.transit.model.site.Station;
import org.opentripplanner.transit.model.site.StopLocation;
import org.opentripplanner.transit.model.site.StopLocationsGroup;
import org.opentripplanner.transit.service.TransitService;
Expand Down Expand Up @@ -153,7 +155,7 @@ StopCluster.Location toLocation(FeedScopedId id) {
.toList();
return new StopCluster.Location(
group.getId(),
group.getCode(),
extractCode(group),
STATION,
group.getName().toString(),
new StopCluster.Coordinate(group.getLat(), group.getLon()),
Expand All @@ -164,6 +166,15 @@ StopCluster.Location toLocation(FeedScopedId id) {
}
}

@Nullable
private static String extractCode(StopLocationsGroup group) {
if (group instanceof Station station) {
return station.getCode();
} else {
return null;
}
}

private static StopCluster.Coordinate toCoordinate(WgsCoordinate c) {
return new StopCluster.Coordinate(c.latitude(), c.longitude());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,6 @@ public WgsCoordinate getCoordinate() {
return coordinate;
}

@Nullable
@Override
public String getCode() {
return null;
}

@Nonnull
public Collection<StopLocation> getChildStops() {
return this.childStations.stream().flatMap(s -> s.getChildStops().stream()).toList();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.opentripplanner.transit.model.site;

import java.util.Collection;
import javax.annotation.Nullable;
import org.opentripplanner.framework.geometry.WgsCoordinate;
import org.opentripplanner.framework.i18n.I18NString;
import org.opentripplanner.framework.lang.ObjectUtils;
Expand Down Expand Up @@ -40,7 +39,4 @@ default double getLon() {
default String logName() {
return ObjectUtils.ifNotNull(getName(), Object::toString, null);
}

@Nullable
String getCode();
}

0 comments on commit ab5ec25

Please sign in to comment.