001package cn.mybatis.mp.generator.strategy;
002
003import cn.mybatis.mp.core.util.NamingUtil;
004
005/**
006 * 名字策略
007 */
008public enum NamingStrategy {
009
010    /**
011     * 不做任何改变,原样输出
012     */
013    NO_CHANGE,
014
015    /**
016     * 下划线转驼峰命名
017     */
018    UNDERLINE_TO_CAMEL;
019
020    /**
021     * 获取名字
022     *
023     * @param sourceName     原始名字
024     * @param firstUpperCase 首字母大小写
025     * @return
026     */
027    public String getName(String sourceName, boolean firstUpperCase) {
028        if (this == NO_CHANGE) {
029            return sourceName;
030        }
031        sourceName = NamingUtil.underlineToCamel(sourceName);
032        return firstUpperCase ? NamingUtil.firstToLower(sourceName) : sourceName;
033    }
034}