@Test public void extractParameters() { GraphiteNamePattern pattern; Map<String, String> expected = new HashMap<String, String>(); expected.put("${0}", "gather"); expected.put("${1}", "400"); pattern = new GraphiteNamePattern("org.test.controller.*.status.*"); Assertions.assertThat(pattern.extractParameters("org.test.controller.gather.status.400")) .isEqualTo(expected); expected = new HashMap<String, String>(); expected.put("${0}", "org"); expected.put("${1}", "gather"); expected.put("${2}", "400"); pattern = new GraphiteNamePattern("*.test.controller.*.status.*"); Assertions.assertThat(pattern.extractParameters("org.test.controller.gather.status.400")) .isEqualTo(expected); }
Map<String, String> extractParameters(final String metricName) { final Matcher matcher = this.pattern.matcher(metricName); final Map<String, String> params = new HashMap<String, String>(); if (matcher.find()) { for (int i = 1; i <= matcher.groupCount(); i++) { params.put(String.format("${%d}", i - 1), matcher.group(i)); } } return params; }
GraphiteNamePattern { Map<String, String> extractParameters(final String metricName) { final Matcher matcher = this.pattern.matcher(metricName); final Map<String, String> params = new HashMap<String, String>(); if (matcher.find()) { for (int i = 1; i <= matcher.groupCount(); i++) { params.put(String.format("${%d}", i - 1), matcher.group(i)); } } return params; } }
GraphiteNamePattern { Map<String, String> extractParameters(final String metricName) { final Matcher matcher = this.pattern.matcher(metricName); final Map<String, String> params = new HashMap<String, String>(); if (matcher.find()) { for (int i = 1; i <= matcher.groupCount(); i++) { params.put(String.format("${%d}", i - 1), matcher.group(i)); } } return params; } GraphiteNamePattern(final String pattern); }
GraphiteNamePattern { Map<String, String> extractParameters(final String metricName) { final Matcher matcher = this.pattern.matcher(metricName); final Map<String, String> params = new HashMap<String, String>(); if (matcher.find()) { for (int i = 1; i <= matcher.groupCount(); i++) { params.put(String.format("${%d}", i - 1), matcher.group(i)); } } return params; } GraphiteNamePattern(final String pattern);  }
GraphiteNamePattern { Map<String, String> extractParameters(final String metricName) { final Matcher matcher = this.pattern.matcher(metricName); final Map<String, String> params = new HashMap<String, String>(); if (matcher.find()) { for (int i = 1; i <= matcher.groupCount(); i++) { params.put(String.format("${%d}", i - 1), matcher.group(i)); } } return params; } GraphiteNamePattern(final String pattern);   }