String pattern matching - method needs improving
The function getTokenValues is actually a pattern matching function. It just uses a different syntax than the pattern format of java.util.regex.

I suggest you to convert your pattern string (the one with $ signs) into a valid Pattern.

${1}/andThen/${2}/followedBy/${3}


becomes

(.+?)/andThen/(.+?)/followedBy/(.+?)


And then you can use Pattern.matcher to find the content of the groups. There is still one thing missing : the fact that the numbering of the original pattern is lost. For that, you can parse the original pattern string to extract those numbers, to create a mapping table.

When you convert your pattern string into a Pattern, be careful to escape the substrings between the $ using Pattern.quote().

I don't know if this solution would be an improvement of yours, but it's an alternative to consider.

Edit

The implementation of my solution :

Map&lt;String, String&gt; getTokenValues(String pattern, String str) {
    Map&lt;String, String&gt; res = new HashMap&lt;String, String&gt;();
    List&lt;String&gt; identifiers = new ArrayList&lt;String&gt;();

    Pattern dollarRgx = Pattern.compile("\\$\\{([0-9]+?)\\}");
    Matcher dollarMatcher = dollarRgx.matcher(pattern);
    StringBuilder convRgxBd = new StringBuilder();
    int lastEnd = 0;
    while(dollarMatcher.find()) {
        String before = pattern.substring(lastEnd, dollarMatcher.start());
        convRgxBd.append(Pattern.quote(before));
        convRgxBd.append("(.+?)");
        lastEnd = dollarMatcher.end();
        identifiers.add(dollarMatcher.group(1));
    }
    String after = pattern.substring(lastEnd, pattern.length());
    convRgxBd.append(Pattern.quote(after));

    Pattern convRgx = Pattern.compile(convRgxBd.toString());
    Matcher convMatcher = convRgx.matcher(str);
    if(convMatcher.matches()) {
        for(int i = 0; i &lt; convMatcher.groupCount(); i++) {
            String id = identifiers.get(i);
            res.put(id, convMatcher.group(i+1));
        }
    }

    return res;
}