org.opentripplanner.ext.legacygraphqlapi.datafetchers.LegacyGraphQLPlaceImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of otp Show documentation
Show all versions of otp Show documentation
The OpenTripPlanner multimodal journey planning system
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 arrivalTime() {
return environment -> getSource(environment).arrival.toInstant().toEpochMilli();
}
@Override
public DataFetcher bikePark() {
return this::getBikePark;
}
@Override
public DataFetcher bikeRentalStation() {
return environment -> {
Place place = getSource(environment).place;
if (!place.vertexType.equals(VertexType.VEHICLERENTAL)) {
return null;
}
return place.vehicleRentalPlace;
};
}
@Override
public DataFetcher carPark() {
return this::getCarPark;
}
@Override
public DataFetcher departureTime() {
return environment -> getSource(environment).departure.toInstant().toEpochMilli();
}
@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 name() {
return environment -> {
Locale locale = LegacyGraphQLUtils.getLocale(environment);
return getSource(environment).place.name.toString(locale);
};
}
@Override
public DataFetcher rentalVehicle() {
return environment -> {
Place place = getSource(environment).place;
if (
!place.vertexType.equals(VertexType.VEHICLERENTAL) ||
!(place.vehicleRentalPlace instanceof VehicleRentalVehicle)
) {
return null;
}
return (VehicleRentalVehicle) place.vehicleRentalPlace;
};
}
@Override
public DataFetcher
© 2015 - 2025 Weber Informatics LLC | Privacy Policy