package org.wso2.carbon.databridge.agent.thrift.util;

import java.util.ArrayList;
import java.util.regex.Matcher;
import java.util.regex.Pattern;


public class DataPublisherUtil {

    public static ArrayList<String> getReceiverGroups(String urls) {
        ArrayList<String> matchList = new ArrayList<String>();
        Pattern regex = Pattern.compile("\\{.*?\\}");
        Matcher regexMatcher = regex.matcher(urls);
        while (regexMatcher.find()) {
            matchList.add(regexMatcher.group().replace("{", "").replace("}", ""));
        }
        if (matchList.size() == 0) {
            matchList.add(urls.replace("{", "").replace("}", ""));
        }
        return matchList;
    }

    public static String getStreamCacheKey(String streamName, String version) {
        StringBuilder sb = new StringBuilder();
        sb.append(streamName);
        sb.append("_");
        sb.append(version);
        return sb.toString();
    }

}
