@Test public void shouldCaptureValuesFromSimplePattern() { capturer.captureValuesFromPattern("(.*) world", Lists.newArrayList("hello"), "Hi world"); verify(world).put("hello", "Hi"); }
void captureValuesFromPattern(String regexPattern, List<String> groups, String value) { Matcher matcher = Pattern.compile(regexPattern).matcher(value); for (int i = 1; matcher.find(); i++) { if (matcher.group().isEmpty()) return; String groupValue = matcher.group(i); String key = groups.get(i - 1); world.put(key, groupValue); } }
ContextCapturer extends BaseContextHandler { void captureValuesFromPattern(String regexPattern, List<String> groups, String value) { Matcher matcher = Pattern.compile(regexPattern).matcher(value); for (int i = 1; matcher.find(); i++) { if (matcher.group().isEmpty()) return; String groupValue = matcher.group(i); String key = groups.get(i - 1); world.put(key, groupValue); } } }
ContextCapturer extends BaseContextHandler { void captureValuesFromPattern(String regexPattern, List<String> groups, String value) { Matcher matcher = Pattern.compile(regexPattern).matcher(value); for (int i = 1; matcher.find(); i++) { if (matcher.group().isEmpty()) return; String groupValue = matcher.group(i); String key = groups.get(i - 1); world.put(key, groupValue); } }  }
ContextCapturer extends BaseContextHandler { void captureValuesFromPattern(String regexPattern, List<String> groups, String value) { Matcher matcher = Pattern.compile(regexPattern).matcher(value); for (int i = 1; matcher.find(); i++) { if (matcher.group().isEmpty()) return; String groupValue = matcher.group(i); String key = groups.get(i - 1); world.put(key, groupValue); } }  void capture(String pattern, String value); }
ContextCapturer extends BaseContextHandler { void captureValuesFromPattern(String regexPattern, List<String> groups, String value) { Matcher matcher = Pattern.compile(regexPattern).matcher(value); for (int i = 1; matcher.find(); i++) { if (matcher.group().isEmpty()) return; String groupValue = matcher.group(i); String key = groups.get(i - 1); world.put(key, groupValue); } }  void capture(String pattern, String value); static final String GROUP_PATTERN_REGEX; }