package com.duiba.tuia.youtui.web.embed;

import org.apache.commons.lang.StringUtils;

/**
 * Created by wubo on 2017/9/1.
 */
public class DuibaMonitor {

    private static final String SPLIT = ".";

    public static String build(Object a, Object b, Object c, Object d) {
        return new StringBuilder().append(a).append(SPLIT).append(b).append(SPLIT).append(c).append(SPLIT).append(d).toString();
    }

    public static String getParam(String dm, int index) {
        if (StringUtils.isEmpty(dm) || index > 4 || index <= 0) {
            return StringUtils.EMPTY;
        }
        String[] s1 = StringUtils.split(dm, ".");
        return s1[index - 1];
    }

    public static String getCD(String dm) {
        if (StringUtils.isBlank(dm)) {
            return null;
        }
        String[] s1 = StringUtils.split(dm, ".");
        if (s1.length != 4) {//异常数据
            return null;
        }
        return s1[2] + "." + s1[3];
    }
}
