presto-resource-group-managers/src/main/java/io/prestosql/plugin/resourcegroups/ResourceGroupNameTemplate.java/ResourceGroupNameTemplate/ResourceGroupNameTemplate
class ResourceGroupNameTemplate:    @JsonCreator
    public ResourceGroupNameTemplate(String name)
    {
        checkArgument(!name.isEmpty(), "Resource group name is empty");
        checkArgument(name.indexOf('.') < 0, "Invalid resource group name. '%s' contains a '.'", name);
        String nameNoVariables = VARIABLE_PATTERN.matcher(name).replaceAll("");
        checkArgument(
                !(nameNoVariables.contains("{") || nameNoVariables.contains("}") || nameNoVariables.contains("$")),
                "Invalid resource group name. '%s' contains extraneous '$', '{', or '}", name);

        ImmutableList.Builder<NameFragment> builder = ImmutableList.builder();
        Matcher matcher = VARIABLE_PATTERN.matcher(name);
        int lastMatchEnd = 0;
        while (matcher.find()) {
            int matchBegin = matcher.start();
            int matchEnd = matcher.end();
            if (matchBegin > lastMatchEnd) {
                builder.add(NameFragment.literal(name.substring(lastMatchEnd, matchBegin)));
            }
            builder.add(NameFragment.variable(name.substring(matchBegin + 2, matchEnd - 1)));
            lastMatchEnd = matchEnd;
        }

        if (lastMatchEnd != name.length()) {
            builder.add(NameFragment.literal(name.substring(lastMatchEnd, name.length())));
        }

        this.fragments = builder.build();
    }