forked from opentripplanner/OpenTripPlanner
-
Notifications
You must be signed in to change notification settings - Fork 30
/
StopRelationshipImpl.java
29 lines (24 loc) · 1.02 KB
/
StopRelationshipImpl.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package org.opentripplanner.ext.gtfsgraphqlapi.datafetchers;
import graphql.schema.DataFetcher;
import graphql.schema.DataFetchingEnvironment;
import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLDataFetchers.GraphQLStopRelationship;
import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes.GraphQLVehicleStopStatus;
import org.opentripplanner.service.realtimevehicles.model.RealtimeVehicle.StopRelationship;
public class StopRelationshipImpl implements GraphQLStopRelationship {
@Override
public DataFetcher<Object> status() {
return env ->
switch (getSource(env).status()) {
case INCOMING_AT -> GraphQLVehicleStopStatus.INCOMING_AT;
case IN_TRANSIT_TO -> GraphQLVehicleStopStatus.IN_TRANSIT_TO;
case STOPPED_AT -> GraphQLVehicleStopStatus.STOPPED_AT;
};
}
@Override
public DataFetcher<Object> stop() {
return env -> getSource(env).stop();
}
private StopRelationship getSource(DataFetchingEnvironment environment) {
return environment.getSource();
}
}