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

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

package org.opentripplanner.ext.legacygraphqlapi.datafetchers;

import graphql.schema.DataFetcher;
import graphql.schema.DataFetchingEnvironment;
import java.util.Map;
import org.opentripplanner.ext.legacygraphqlapi.generated.LegacyGraphQLDataFetchers;
import org.opentripplanner.routing.core.FareComponent;
import org.opentripplanner.routing.core.Money;

public class LegacyGraphQLfareImpl implements LegacyGraphQLDataFetchers.LegacyGraphQLFare {

  @Override
  public DataFetcher cents() {
    return environment -> ((Money) getSource(environment).get("fare")).cents();
  }

  @Override
  public DataFetcher> components() {
    return environment -> (Iterable) getSource(environment).get("details");
  }

  @Override
  public DataFetcher currency() {
    return environment -> ((Money) getSource(environment).get("fare")).currency().getCurrencyCode();
  }

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

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




© 2015 - 2025 Weber Informatics LLC | Privacy Policy