You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
private Fare _getCost(GraphPath path, Set<String> allowedFareIds) {
List<Ride> rides = createRides(path);
// If there are no rides, there's no fare.
if (rides.size() == 0) {
return null;
}
Fare fare = new Fare();
boolean hasFare = false;
for (Map.Entry<FareType, Collection<FareRuleSet>> kv : fareRulesPerType.entrySet()) {
FareType fareType = kv.getKey();
Collection<FareRuleSet> fareRules;
if (allowedFareIds != null) {
fareRules = kv.getValue().stream()
.filter(f -> allowedFareIds.contains(f.getFareAttribute().getId().toString()))
.collect(Collectors.toList());
} else {
fareRules = kv.getValue();
}
// Get the currency from the first fareAttribute, assuming that all tickets use the same
// currency.
Currency currency = null;
if (fareRules.size() > 0) {
currency =
Currency.getInstance(fareRules.iterator().next().getFareAttribute().getCurrencyType());
}
hasFare = populateFare(fare, currency, fareType, rides, fareRules);
// log.info("Fares for {} available: {}", fareType, hasFare);
}
return hasFare ? fare : null;
}
inside the for loop, if we have 4 fareTypes need to calculate, let's assume the result as below:
1_fareType : hasFare = true
2_fareType: hasFare = true
3_fareType: hasFare = true
4_fareType: hasFare = false
what will be the result return from this method ? null right ?
I wonder this is written as design or it's a logic error.
if it's a logic error , I advice to update the code to be hasFare = populateFare(fare, currency, fareType, rides, fareRules) || hasFare;
The text was updated successfully, but these errors were encountered:
Here is the code in org.opentripplanner.routing.impl.DefaultFareServiceImpl.java :
inside the for loop, if we have 4 fareTypes need to calculate, let's assume the result as below:
1_fareType : hasFare = true
2_fareType: hasFare = true
3_fareType: hasFare = true
4_fareType: hasFare = false
what will be the result return from this method ? null right ?
I wonder this is written as design or it's a logic error.
if it's a logic error , I advice to update the code to be
hasFare = populateFare(fare, currency, fareType, rides, fareRules) || hasFare;
The text was updated successfully, but these errors were encountered: