From cb6965269c00b88d3f8dfc842a5e061155b3fd6a Mon Sep 17 00:00:00 2001 From: Daniel Heppner Date: Tue, 12 Dec 2023 15:27:21 -0800 Subject: [PATCH] refactor code for neatness --- .../ext/fares/impl/OrcaFareService.java | 26 +++++++------------ 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/src/ext/java/org/opentripplanner/ext/fares/impl/OrcaFareService.java b/src/ext/java/org/opentripplanner/ext/fares/impl/OrcaFareService.java index 760ff5517bd..48904d7d3e4 100644 --- a/src/ext/java/org/opentripplanner/ext/fares/impl/OrcaFareService.java +++ b/src/ext/java/org/opentripplanner/ext/fares/impl/OrcaFareService.java @@ -299,22 +299,14 @@ private Optional getSeniorFare( Leg leg ) { var route = leg.getRoute(); + var regularFare = getRegularFare(fareType, rideType, defaultFare, leg); + // Many agencies only provide senior discount if using ORCA return switch (rideType) { - case COMM_TRANS_LOCAL_SWIFT -> usesOrca(fareType) - ? optionalUSD(1.25f) - : getRegularFare(fareType, rideType, defaultFare, leg); - case COMM_TRANS_COMMUTER_EXPRESS -> usesOrca(fareType) - ? optionalUSD(2f) - : getRegularFare(fareType, rideType, defaultFare, leg); + case COMM_TRANS_LOCAL_SWIFT -> usesOrca(fareType) ? optionalUSD(1.25f) : regularFare; + case COMM_TRANS_COMMUTER_EXPRESS -> usesOrca(fareType) ? optionalUSD(2f) : regularFare; case EVERETT_TRANSIT, SKAGIT_TRANSIT, WHATCOM_LOCAL, SKAGIT_LOCAL -> optionalUSD(0.5f); - case KITSAP_TRANSIT_FAST_FERRY_EASTBOUND -> fareType.equals(FareType.electronicSenior) // Kitsap only provide discounted senior fare for orca. - ? optionalUSD(1f) - : optionalUSD(2f); - case KC_WATER_TAXI_VASHON_ISLAND -> usesOrca(fareType) ? optionalUSD(3f) : optionalUSD(6.75f); - case KC_WATER_TAXI_WEST_SEATTLE -> usesOrca(fareType) - ? optionalUSD(2.5f) - : optionalUSD(5.75f); - case SOUND_TRANSIT, + case KITSAP_TRANSIT_FAST_FERRY_EASTBOUND, + SOUND_TRANSIT, SOUND_TRANSIT_BUS, SOUND_TRANSIT_LINK, SOUND_TRANSIT_SOUNDER, @@ -324,10 +316,12 @@ private Optional getSeniorFare( SEATTLE_STREET_CAR, KITSAP_TRANSIT -> fareType.equals(FareType.electronicSenior) ? optionalUSD(1f) - : getRegularFare(fareType, rideType, defaultFare, leg); + : regularFare; + case KC_WATER_TAXI_VASHON_ISLAND -> usesOrca(fareType) ? optionalUSD(3f) : regularFare; + case KC_WATER_TAXI_WEST_SEATTLE -> usesOrca(fareType) ? optionalUSD(2.5f) : regularFare; case KITSAP_TRANSIT_FAST_FERRY_WESTBOUND -> fareType.equals(FareType.electronicSenior) ? optionalUSD(5f) - : optionalUSD(10f); + : regularFare; // Discount specific to Skagit transit and not Orca. case WASHINGTON_STATE_FERRIES -> Optional.of( getWashingtonStateFerriesFare(route.getLongName(), fareType, defaultFare)