org.opentripplanner.ext.legacygraphqlapi.datafetchers.LegacyGraphQLItineraryImpl Maven / Gradle / Ivy
package org.opentripplanner.ext.legacygraphqlapi.datafetchers;
import graphql.schema.DataFetcher;
import graphql.schema.DataFetchingEnvironment;
import org.opentripplanner.ext.legacygraphqlapi.generated.LegacyGraphQLDataFetchers;
import org.opentripplanner.model.plan.Itinerary;
import org.opentripplanner.model.plan.Leg;
import org.opentripplanner.routing.core.Fare;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
public class LegacyGraphQLItineraryImpl
implements LegacyGraphQLDataFetchers.LegacyGraphQLItinerary {
@Override
public DataFetcher startTime() {
return environment -> getSource(environment).startTime().getTime().getTime();
}
@Override
public DataFetcher endTime() {
return environment -> getSource(environment).endTime().getTime().getTime();
}
@Override
public DataFetcher duration() {
return environment -> (long) getSource(environment).durationSeconds;
}
@Override
public DataFetcher waitingTime() {
return environment -> (long) getSource(environment).waitingTimeSeconds;
}
@Override
public DataFetcher walkTime() {
return environment -> (long) getSource(environment).nonTransitTimeSeconds;
}
@Override
public DataFetcher walkDistance() {
return environment -> getSource(environment).nonTransitDistanceMeters;
}
@Override
public DataFetcher> legs() {
return environment -> getSource(environment).legs;
}
@Override
public DataFetcher>> fares() {
return environment -> {
Fare fare = getSource(environment).fare;
if (fare == null) {
return null;
}
List