package com.tofly.analyse.util.analysis;

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

public class CamelToUtil {

    //转变的依赖字符
    public static final char UNDERLINE='_';

    /**
     * 将"_"转成驼峰(user_id:userId)
     * @param param
     * @return
     */
    public static String underlineToCamel(String param){
        param=param.toLowerCase();
        if (param==null||"".equals(param.trim())){
            return "";
        }
        StringBuilder sb=new StringBuilder(param);
        Matcher mc= Pattern.compile(UNDERLINE+"").matcher(param);
        int i=0;
        while (mc.find()){
            int position=mc.end()-(i++);
            String.valueOf(Character.toUpperCase(sb.charAt(position)));
            sb.replace(position-1,position+1,sb.substring(position,position+1).toUpperCase());
        }
        return sb.toString();
    }

}
