All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.opentripplanner.ext.legacygraphqlapi.datafetchers.LegacyGraphQLBikeParkImpl Maven / Gradle / Ivy

There is a newer version: 2.6.0
Show newest version
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 bikeParkId() {
    return environment -> getSource(environment).getId().getId();
  }

  @Override
  public DataFetcher id() {
    return environment ->
      new Relay.ResolvedGlobalId("BikePark", getSource(environment).getId().toString());
  }

  @Override
  public DataFetcher lat() {
    return environment -> getSource(environment).getCoordinate().latitude();
  }

  @Override
  public DataFetcher lon() {
    return environment -> getSource(environment).getCoordinate().longitude();
  }

  @Override
  public DataFetcher name() {
    return environment -> getSource(environment).getName().toString();
  }

  // TODO
  @Override
  public DataFetcher> openingHours() {
    return environment -> null;
  }

  @Override
  public DataFetcher realtime() {
    return environment -> getSource(environment).hasRealTimeData();
  }

  @Override
  public DataFetcher spacesAvailable() {
    return environment -> {
      var availability = getSource(environment).getAvailability();
      if (availability == null) {
        return null;
      }
      return availability.getBicycleSpaces();
    };
  }

  @Override
  public DataFetcher> tags() {
    return environment -> getSource(environment).getTags();
  }

  private VehicleParking getSource(DataFetchingEnvironment environment) {
    return environment.getSource();
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy