@Test public void convertMetricsTest() throws ParameterValueException { Assert.assertEquals(1, MatrixRequestHandler.convertMetrics(new MatrixRequestEnums.Metrics[] {MatrixRequestEnums.Metrics.DURATION})); Assert.assertEquals(2, MatrixRequestHandler.convertMetrics(new MatrixRequestEnums.Metrics[] {MatrixRequestEnums.Metrics.DISTANCE})); Assert.assertEquals(3, MatrixRequestHandler.convertMetrics(new MatrixRequestEnums.Metrics[] {MatrixRequestEnums.Metrics.DURATION, MatrixRequestEnums.Metrics.DISTANCE})); }
public static int convertMetrics(MatrixRequestEnums.Metrics[] metrics) throws ParameterValueException { List<String> metricsAsStrings = new ArrayList<>(); for (int i=0; i<metrics.length; i++) { metricsAsStrings.add(metrics[i].toString()); } String concatMetrics = String.join("|", metricsAsStrings); int combined = MatrixMetricsType.getFromString(concatMetrics); if (combined == MatrixMetricsType.UNKNOWN) throw new ParameterValueException(MatrixErrorCodes.INVALID_PARAMETER_VALUE, MatrixRequest.PARAM_METRICS); return combined; }
MatrixRequestHandler { public static int convertMetrics(MatrixRequestEnums.Metrics[] metrics) throws ParameterValueException { List<String> metricsAsStrings = new ArrayList<>(); for (int i=0; i<metrics.length; i++) { metricsAsStrings.add(metrics[i].toString()); } String concatMetrics = String.join("|", metricsAsStrings); int combined = MatrixMetricsType.getFromString(concatMetrics); if (combined == MatrixMetricsType.UNKNOWN) throw new ParameterValueException(MatrixErrorCodes.INVALID_PARAMETER_VALUE, MatrixRequest.PARAM_METRICS); return combined; } }
MatrixRequestHandler { public static int convertMetrics(MatrixRequestEnums.Metrics[] metrics) throws ParameterValueException { List<String> metricsAsStrings = new ArrayList<>(); for (int i=0; i<metrics.length; i++) { metricsAsStrings.add(metrics[i].toString()); } String concatMetrics = String.join("|", metricsAsStrings); int combined = MatrixMetricsType.getFromString(concatMetrics); if (combined == MatrixMetricsType.UNKNOWN) throw new ParameterValueException(MatrixErrorCodes.INVALID_PARAMETER_VALUE, MatrixRequest.PARAM_METRICS); return combined; } private  MatrixRequestHandler(); }
MatrixRequestHandler { public static int convertMetrics(MatrixRequestEnums.Metrics[] metrics) throws ParameterValueException { List<String> metricsAsStrings = new ArrayList<>(); for (int i=0; i<metrics.length; i++) { metricsAsStrings.add(metrics[i].toString()); } String concatMetrics = String.join("|", metricsAsStrings); int combined = MatrixMetricsType.getFromString(concatMetrics); if (combined == MatrixMetricsType.UNKNOWN) throw new ParameterValueException(MatrixErrorCodes.INVALID_PARAMETER_VALUE, MatrixRequest.PARAM_METRICS); return combined; } private  MatrixRequestHandler(); static MatrixResult generateMatrixFromRequest(MatrixRequest request); static org.heigit.ors.matrix.MatrixRequest convertMatrixRequest(MatrixRequest request); static int convertMetrics(MatrixRequestEnums.Metrics[] metrics); }
MatrixRequestHandler { public static int convertMetrics(MatrixRequestEnums.Metrics[] metrics) throws ParameterValueException { List<String> metricsAsStrings = new ArrayList<>(); for (int i=0; i<metrics.length; i++) { metricsAsStrings.add(metrics[i].toString()); } String concatMetrics = String.join("|", metricsAsStrings); int combined = MatrixMetricsType.getFromString(concatMetrics); if (combined == MatrixMetricsType.UNKNOWN) throw new ParameterValueException(MatrixErrorCodes.INVALID_PARAMETER_VALUE, MatrixRequest.PARAM_METRICS); return combined; } private  MatrixRequestHandler(); static MatrixResult generateMatrixFromRequest(MatrixRequest request); static org.heigit.ors.matrix.MatrixRequest convertMatrixRequest(MatrixRequest request); static int convertMetrics(MatrixRequestEnums.Metrics[] metrics);  }