Skip to content

Commit

Permalink
Rename mapper to BikesAllowedMapper
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardehrenfried committed Sep 21, 2023
1 parent 6138851 commit 0abf7f3
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
import org.junit.jupiter.api.Test;
import org.opentripplanner.transit.model.network.BikeAccess;

class BikeAccessMapperTest {
class BikesAllowedMapperTest {

@Test
void mapping() {
Arrays
.stream(BikeAccess.values())
.filter(ba -> ba != BikeAccess.UNKNOWN)
.forEach(d -> {
var mapped = BikeAccessMapper.map(d);
var mapped = BikesAllowedMapper.map(d);
assertEquals(d.toString(), mapped.toString());
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes;
import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes.GraphQLBikesAllowed;
import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes.GraphQLTransitMode;
import org.opentripplanner.ext.gtfsgraphqlapi.mapping.BikeAccessMapper;
import org.opentripplanner.ext.gtfsgraphqlapi.mapping.BikesAllowedMapper;
import org.opentripplanner.routing.alertpatch.EntitySelector;
import org.opentripplanner.routing.alertpatch.TransitAlert;
import org.opentripplanner.routing.services.TransitAlertService;
Expand Down Expand Up @@ -134,7 +134,7 @@ public DataFetcher<Iterable<TransitAlert>> alerts() {

@Override
public DataFetcher<GraphQLBikesAllowed> bikesAllowed() {
return environment -> BikeAccessMapper.map(getSource(environment).getBikesAllowed());
return environment -> BikesAllowedMapper.map(getSource(environment).getBikesAllowed());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes;
import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes.GraphQLBikesAllowed;
import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes.GraphQLWheelchairBoarding;
import org.opentripplanner.ext.gtfsgraphqlapi.mapping.BikeAccessMapper;
import org.opentripplanner.ext.gtfsgraphqlapi.mapping.BikesAllowedMapper;
import org.opentripplanner.framework.time.ServiceDateUtils;
import org.opentripplanner.model.Timetable;
import org.opentripplanner.model.TripTimeOnDate;
Expand Down Expand Up @@ -168,7 +168,7 @@ public DataFetcher<TripTimeOnDate> arrivalStoptime() {

@Override
public DataFetcher<GraphQLBikesAllowed> bikesAllowed() {
return environment -> BikeAccessMapper.map(getSource(environment).getBikesAllowed());
return environment -> BikesAllowedMapper.map(getSource(environment).getBikesAllowed());
}

@Override
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package org.opentripplanner.ext.gtfsgraphqlapi.mapping;

import javax.annotation.Nonnull;
import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes.GraphQLBikesAllowed;
import org.opentripplanner.transit.model.network.BikeAccess;

public class BikesAllowedMapper {

@Nonnull
public static GraphQLBikesAllowed map(@Nonnull BikeAccess bikesAllowed) {
return switch (bikesAllowed) {
case UNKNOWN -> GraphQLBikesAllowed.NO_INFORMATION;
case ALLOWED -> GraphQLBikesAllowed.ALLOWED;
case NOT_ALLOWED -> GraphQLBikesAllowed.NOT_ALLOWED;
};
}
}

0 comments on commit 0abf7f3

Please sign in to comment.