org.opentripplanner.ext.legacygraphqlapi.datafetchers.LegacyGraphQLBikeParkImpl Maven / Gradle / Ivy
package org.opentripplanner.ext.legacygraphqlapi.datafetchers;
import graphql.relay.Relay;
import graphql.schema.DataFetcher;
import graphql.schema.DataFetchingEnvironment;
import org.opentripplanner.ext.legacygraphqlapi.generated.LegacyGraphQLDataFetchers;
import org.opentripplanner.routing.vehicle_parking.VehicleParking;
public class LegacyGraphQLBikeParkImpl implements LegacyGraphQLDataFetchers.LegacyGraphQLBikePark {
@Override
public DataFetcher id() {
return environment -> new Relay.ResolvedGlobalId(
"BikePark",
getSource(environment).getId().toString()
);
}
@Override
public DataFetcher bikeParkId() {
return environment -> getSource(environment).getId().getId();
}
@Override
public DataFetcher name() {
return environment -> getSource(environment).getName().toString();
}
@Override
public DataFetcher spacesAvailable() {
return environment -> {
var availability = getSource(environment).getAvailability();
if (availability == null) {
return null;
}
return availability.getBicycleSpaces();
};
}
@Override
public DataFetcher realtime() {
return environment -> getSource(environment).hasRealTimeData();
}
@Override
public DataFetcher lon() {
return environment -> getSource(environment).getX();
}
@Override
public DataFetcher lat() {
return environment -> getSource(environment).getY();
}
@Override
public DataFetcher> tags() {
return environment -> getSource(environment).getTags();
}
// TODO
@Override
public DataFetcher> openingHours() {
return environment -> null;
}
private VehicleParking getSource(DataFetchingEnvironment environment) {
return environment.getSource();
}
}