package com.tools.common.util;@b@@b@/**@b@ * 代码生成工具类@b@ * 爪哇笔记:https://blog.52itstyle.vip@b@ */@b@public class GenUtils {@b@@b@ /**@b@ * 由数据库表名生成实体类名@b@ * @param tableName@b@ * @return@b@ */@b@ public static String allInitialCapital(String tableName) {@b@ if (org.springframework.util.StringUtils.isEmpty(tableName)) {@b@ return null;@b@ }@b@ tableName = allLowerCase(tableName);@b@ String[] tableNameArray = splitName(tableName);@b@ StringBuffer entryName = new StringBuffer();@b@ for (String part : tableNameArray) {@b@ entryName.append(initialCapital(part));@b@ }@b@ return entryName.toString();@b@ }@b@ /**@b@ * 由数据库列名生成实体类属性名@b@ * @param columnName@b@ * @return@b@ */@b@ public static String secInitialCapital(String columnName) {@b@ if (org.springframework.util.StringUtils.isEmpty(columnName)) {@b@ return null;@b@ }@b@ columnName = allLowerCase(columnName);@b@ String[] columnNameArray = splitName(columnName);@b@ StringBuffer fieldName = new StringBuffer();@b@ for (int i = 0; i < columnNameArray.length; i++) {@b@ String part = columnNameArray[i];@b@ if (0 == i) {@b@ fieldName.append(part);@b@ } else {@b@ fieldName.append(initialCapital(part));@b@ }@b@ }@b@ return fieldName.toString();@b@ }@b@ /**@b@ * 所有字母转成小写@b@ * @return@b@ */@b@ public static String allLowerCase(String str) {@b@ if (org.springframework.util.StringUtils.isEmpty(str)) {@b@ return str;@b@ }@b@ return str.toLowerCase();@b@ }@b@ /**@b@ * 功能:将输入字符串的首字母改成大写@b@ * @param str@b@ * @return@b@ */@b@ public static String initialCapital(String str) {@b@ char[] ch = str.toCharArray();@b@ if (ch[0] >= 'a' && ch[0] <= 'z') {@b@ ch[0] = (char) (ch[0] - 32);@b@ }@b@ return new String(ch);@b@ }@b@ /**@b@ * 分解名称@b@ * @param str@b@ * @return@b@ */@b@ public static String[] splitName(String str) {@b@ if (org.springframework.util.StringUtils.isEmpty(str)) {@b@ return null;@b@ }@b@ return str.split("_");@b@ }@b@ /**@b@ * 首字母转小写@b@ * @param s@b@ * @return@b@ */@b@ public static String toLowerCaseFirstOne(String s){@b@ if(Character.isLowerCase(s.charAt(0))){@b@ return s;@b@ } else{@b@ return (new StringBuilder()).append(Character.toLowerCase(s.charAt(0))).append(s.substring(1)).toString();@b@ }@b@ }@b@}