if ( router instanceof Dijkstra) ((Dijkstra)router).setModeRestrictions(...)
to an easier-to-read (in my view)
if ( router instanceof IntermodalLeastCostPathCalculator) ((IntermodalLeastCostPathCalculator)router).setModeRestrictions(...)
Also modifications in Manuel's code.