Repository navigation
Allow itinerary in response to be sorted by duration - #2593
Conversation
…ntations can be added following this pattern.
|
Looks good! Maybe PathComparator should be called something else, like ArrivalTimeComparator? I think @t2gran suggested combining this with a pareto-set filter, but that could be added later. |
|
|
||
| /** Which path comparator to use */ | ||
| public String pathComparator = null; | ||
|
|
There was a problem hiding this comment.
I cannot any places where pathComparator is set. I think a comment on how this is used(set to somethingother null) should be documented. Is the plan to integrate with some kind of configuration later, routing request parameter, or just fork the code and inject a different strategy?
There was a problem hiding this comment.
It's not set explicitly in the code, but if you include configuration in router-config.json, it will get set automatically, e.g.
// router-config.json
{
"routingDefaults": {
"pathComparator":"duration"
}
}
This happens via the existing config-setting code:
I'll add code to allow this to be set via an API parameter as well.
There was a problem hiding this comment.
Thank you for the clarification. I think your solution is the best, it might be confusing to have "config" params only.
This PR adds a DurationComparator so that returned itineraries can be sorted by duration, instead of the default method.
More Comparator implementations can be added following this pattern.