private static CodeDependent createCodeByType(EnumElement type, boolean topLevelClass, String packageName,
            Map<String, String> mappedUniName, boolean isUniName) {

        CodeDependent cd = new CodeDependent();

        String defaultClsName = type.name();
        String simpleName = getProxyClassName(defaultClsName, mappedUniName, isUniName);

        // To generate class
        StringBuilder code = new StringBuilder();
        if (topLevelClass) {
            // define package
            code.append("package ").append(packageName).append(CODE_END);
            code.append("\n");
            // add import;
            code.append("import com.baidu.bjf.remoting.protobuf.EnumReadable;\n");
        }

        // define class
        // define class
        if (topLevelClass) {
            code.append("public enum ");
        } else {
            code.append("public static enum ");
        }
        code.append(simpleName).append(" implements EnumReadable {\n");

        Iterator<EnumConstantElement> iter = type.constants().iterator();
        while (iter.hasNext()) {
            EnumConstantElement value = iter.next();
            String name = value.name();
            int tag = value.tag();

            code.append(name).append("(").append(tag).append(")");
            if (iter.hasNext()) {
                code.append(",");
            } else {
                code.append(";\n");
            }
        }

        code.append("private final int value;\n");
        code.append(simpleName).append("(int value) { this.value = value;  }\n");
        code.append("public int value() { return value; }\n");
        code.append("}\n");

        cd.name = simpleName;
        cd.pkg = packageName;
        cd.code = code.toString();

        return cd;
    }
private static CodeDependent createCodeByType ( EnumElement type , boolean topLevelClass , String packageName , Map < String , String > mappedUniName , boolean isUniName ) { CodeDependent cd = new CodeDependent ( ) ; String defaultClsName = type . name ( ) ; String simpleName = getProxyClassName ( defaultClsName , mappedUniName , isUniName ) ; StringBuilder code = new StringBuilder ( ) ; if ( topLevelClass ) { code . append ( "package " ) . append ( packageName ) . append ( CODE_END ) ; code . append ( "\n" ) ; code . append ( "import com.baidu.bjf.remoting.protobuf.EnumReadable;\n" ) ; } if ( topLevelClass ) { code . append ( "public enum " ) ; } else { code . append ( "public static enum " ) ; } code . append ( simpleName ) . append ( " implements EnumReadable {\n" ) ; Iterator < EnumConstantElement > iter = type . constants ( ) . iterator ( ) ; while ( iter . hasNext ( ) ) { EnumConstantElement value = iter . next ( ) ; String name = value . name ( ) ; int tag = value . tag ( ) ; code . append ( name ) . append ( "(" ) . append ( tag ) . append ( ")" ) ; if ( iter . hasNext ( ) ) { code . append ( "," ) ; } else { code . append ( ";\n" ) ; } } code . append ( "private final int value;\n" ) ; code . append ( simpleName ) . append ( "(int value) { this.value = value;  }\n" ) ; code . append ( "public int value() { return value; }\n" ) ; code . append ( "}\n" ) ; cd . name = simpleName ; cd . pkg = packageName ; cd . code = code . toString ( ) ; return cd ; }
Creates the code by type.

@param type the type
@param topLevelClass the top level class
@param packageName the package name
@param mappedUniName the mapped uni name
@param isUniName the is uni name
@return the code dependent