RegexMountPoint { public static Map<String, Set<String>> getVarListInString(String input) { Map<String, Set<String>> varMap = new HashMap<>(); Matcher matcher = VAR_PATTERN_IN_DEST.matcher(input); while (matcher.find()) { String varName = matcher.group(0); String strippedVarName = matcher.group(1); if (strippedVarName.startsWith("{")) { strippedVarName = strippedVarName.substring(1, strippedVarName.length() - 1); } varMap.putIfAbsent(strippedVarName, new HashSet<>()); varMap.get(strippedVarName).add(varName); } return varMap; } RegexMountPoint(InodeTree inodeTree, String sourcePathRegex,
      String destPath, String settingsStr); Map<String, Set<String>> getVarInDestPathMap(); void initialize(); static Map<String, Set<String>> getVarListInString(String input); String getSrcPathRegex(); Pattern getSrcPattern(); String getDstPath(); static Pattern getVarPatternInDest(); InodeTree.ResolveResult<T> resolve(final String srcPath,
      final boolean resolveLastComponent); static final String SETTING_SRCREGEX_SEP; static final char INTERCEPTOR_SEP; static final char INTERCEPTOR_INTERNAL_SEP; static final Pattern VAR_PATTERN_IN_DEST; }
@Test public void testGetVarListInString() throws IOException { String srcRegex = "/(\\w+)"; String target = "/$0/${1}/$1/${2}/${2}"; RegexMountPoint regexMountPoint = new RegexMountPoint(inodeTree, srcRegex, target, null); regexMountPoint.initialize(); Map<String, Set<String>> varMap = regexMountPoint.getVarInDestPathMap(); Assert.assertEquals(varMap.size(), 3); Assert.assertEquals(varMap.get("0").size(), 1); Assert.assertTrue(varMap.get("0").contains("$0")); Assert.assertEquals(varMap.get("1").size(), 2); Assert.assertTrue(varMap.get("1").contains("${1}")); Assert.assertTrue(varMap.get("1").contains("$1")); Assert.assertEquals(varMap.get("2").size(), 1); Assert.assertTrue(varMap.get("2").contains("${2}")); }