All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.gitee.fufu669.utils.CacheTableUtil Maven / Gradle / Ivy

There is a newer version: 6.666.66021
Show newest version
package com.gitee.fufu669.utils;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @author wangfupeng
 */
public class CacheTableUtil {

    public static final Logger logger = LoggerFactory.getLogger(CacheStringUtils.class);

    public static String toTransferTableNameToObjectName(String tableName) {
        String[] tableNames = tableName.split("_");
        String objectName = "";
        for (int i = 0; i < tableNames.length; i++) {
            objectName += toUpperCaseAtFirstCharacter(tableNames[i]);
        }
        return objectName;
    }

    public static String toUpperCaseAtFirstCharacter(String tableName) {
        StringBuilder sb = new StringBuilder(tableName);
        sb.setCharAt(0, Character.toUpperCase(sb.charAt(0)));
        return sb.toString();
    }

    public static String toLowerCaseAtFirstCharacter(String tableName) {
        StringBuilder sb = new StringBuilder(tableName);
        sb.setCharAt(0, Character.toLowerCase(sb.charAt(0)));
        return sb.toString();
    }

    public static String getProperCase(String s) {
        return s.substring(0, 1).toUpperCase() + s.substring(1);
    }

    public static String getLowerCaseAndSpliter(String s, String spliter) {
        if (s == null) {
            return "";
        }
        if (s.equals("")) {
            return "";
        }
        String result = ("" + s.charAt(0)).toLowerCase();
        for (int i = 1; i < s.length(); i++) {
            String c = "" + s.charAt(i);
            if (c.toUpperCase().equals(c)) {
                result += spliter + c.toLowerCase();
            } else {
                result += c;
            }
        }
        return result;
    }


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy