org.opentripplanner.ext.legacygraphqlapi.datafetchers.LegacyGraphQLPlaceImpl Maven / Gradle / Ivy
package org.opentripplanner.ext.legacygraphqlapi.datafetchers;
import graphql.schema.DataFetcher;
import graphql.schema.DataFetchingEnvironment;
import java.util.Locale;
import org.opentripplanner.ext.legacygraphqlapi.LegacyGraphQLRequestContext;
import org.opentripplanner.ext.legacygraphqlapi.LegacyGraphQLUtils;
import org.opentripplanner.ext.legacygraphqlapi.generated.LegacyGraphQLDataFetchers;
import org.opentripplanner.ext.legacygraphqlapi.generated.LegacyGraphQLTypes.LegacyGraphQLVertexType;
import org.opentripplanner.model.plan.Place;
import org.opentripplanner.model.plan.StopArrival;
import org.opentripplanner.model.plan.VertexType;
import org.opentripplanner.routing.RoutingService;
import org.opentripplanner.routing.vehicle_parking.VehicleParking;
import org.opentripplanner.routing.vehicle_rental.VehicleRentalPlace;
import org.opentripplanner.routing.vehicle_rental.VehicleRentalStation;
import org.opentripplanner.routing.vehicle_rental.VehicleRentalVehicle;
public class LegacyGraphQLPlaceImpl implements LegacyGraphQLDataFetchers.LegacyGraphQLPlace {
@Override
public DataFetcher name() {
return environment -> {
Locale locale = LegacyGraphQLUtils.getLocale(environment);
return getSource(environment).place.name.toString(locale);
};
}
@Override
public DataFetcher vertexType() {
return environment -> {
var place = getSource(environment).place;
switch (place.vertexType) {
case NORMAL:
return LegacyGraphQLVertexType.NORMAL.name();
case TRANSIT:
return LegacyGraphQLVertexType.TRANSIT.name();
case VEHICLERENTAL:
return LegacyGraphQLVertexType.BIKESHARE.name();
case VEHICLEPARKING:
return LegacyGraphQLVertexType.BIKEPARK.name();
default:
throw new IllegalStateException("Unhandled vertexType: " + place.vertexType.name());
}
};
}
@Override
public DataFetcher lat() {
return environment -> getSource(environment).place.coordinate.latitude();
}
@Override
public DataFetcher lon() {
return environment -> getSource(environment).place.coordinate.longitude();
}
@Override
public DataFetcher arrivalTime() {
return environment -> getSource(environment).arrival.getTime().getTime();
}
@Override
public DataFetcher departureTime() {
return environment -> getSource(environment).departure.getTime().getTime();
}
@Override
public DataFetcher