Source:
<code><START> private AlgorithmOptions.Builder buildOptions(GHMatrixRequest request, GraphHopper hopper){ <END> String algoStr = request.getAlgorithm().isEmpty() ? MatrixAlgorithm.OneToOneLoop : request.getAlgorithm(); TraversalMode tMode; String tModeStr = request.getHints().get("traversal_mode", TraversalMode.NODE_BASED.toString()); try { tMode = TraversalMode.fromString(tModeStr); } catch (Exception ex) { throw new IllegalStateException("Invalid TraversalMode"); } FlagEncoder encoder = hopper.getEncodingManager().getEncoder(request.getVehicle()); RoutingAlgorithmFactory tmpAlgoFactory = hopper.getAlgorithmFactory(request.getHints()); Weighting weighting; if (hopper.getCHFactoryDecorator().isEnabled()) { if (tmpAlgoFactory instanceof PrepareContractionHierarchies){ weighting = ((PrepareContractionHierarchies) tmpAlgoFactory).getWeighting(); }else { throw new IllegalStateException("Although CH was enabled a non-CH algorithm factory was returned " + tmpAlgoFactory); } } else weighting = hopper.createWeighting(request.getHints(), encoder); int maxVisitedNodes = Integer.MAX_VALUE; int maxVisistedNodesForRequest = request.getHints().getInt("routing.maxVisitedNodes", maxVisitedNodes); if (maxVisistedNodesForRequest > maxVisitedNodes) { throw new IllegalStateException("The routing.maxVisitedNodes parameter has to be below or equal to:" + maxVisitedNodes); } return AlgorithmOptions.start(). algorithm(algoStr) .traversalMode(tMode) .flagEncoder(encoder) .weighting(weighting) .maxVisitedNodes(maxVisistedNodesForRequest) .hints(request.getHints()); }</code><technical_language>Yeah, is a good idea separate this in GraphHopper well</technical_language>

Target:
private AlgorithmOptions.Builder buildOptions(GHMatrixRequest request, GraphHopper hopper){ String algoStr = request.getAlgorithm().isEmpty() ? MATRIX_ONE_TO_ONE : request.getAlgorithm(); TraversalMode tMode; String tModeStr = request.getHints().get("traversal_mode", TraversalMode.NODE_BASED.toString()); try { tMode = TraversalMode.fromString(tModeStr); } catch (Exception ex) { throw new IllegalStateException("Invalid TraversalMode"); } FlagEncoder encoder = hopper.getEncodingManager().getEncoder(request.getVehicle()); RoutingAlgorithmFactory tmpAlgoFactory = hopper.getAlgorithmFactory(request.getHints()); Weighting weighting; if (hopper.getCHFactoryDecorator().isEnabled()) { if (tmpAlgoFactory instanceof PrepareContractionHierarchies){ weighting = ((PrepareContractionHierarchies) tmpAlgoFactory).getWeighting(); }else { throw new IllegalStateException("Although CH was enabled a non-CH algorithm factory was returned " + tmpAlgoFactory); } } else weighting = hopper.createWeighting(request.getHints(), encoder); int maxVisitedNodes = Integer.MAX_VALUE; int maxVisistedNodesForRequest = request.getHints().getInt("routing.maxVisitedNodes", maxVisitedNodes); if (maxVisistedNodesForRequest > maxVisitedNodes) { throw new IllegalStateException("The routing.maxVisitedNodes parameter has to be below or equal to:" + maxVisitedNodes); } return AlgorithmOptions.start(). algorithm(algoStr) .traversalMode(tMode) .flagEncoder(encoder) .weighting(weighting) .maxVisitedNodes(maxVisistedNodesForRequest) .hints(request.getHints()); }