当前位置: 首页>>代码示例>>Java>>正文


Java TopLevelClass.addAnnotation方法代码示例

本文整理汇总了Java中org.mybatis.generator.api.dom.java.TopLevelClass.addAnnotation方法的典型用法代码示例。如果您正苦于以下问题:Java TopLevelClass.addAnnotation方法的具体用法?Java TopLevelClass.addAnnotation怎么用?Java TopLevelClass.addAnnotation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.mybatis.generator.api.dom.java.TopLevelClass的用法示例。


在下文中一共展示了TopLevelClass.addAnnotation方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: processEntityClass

import org.mybatis.generator.api.dom.java.TopLevelClass; //导入方法依赖的package包/类
/**
 * 处理实体类的包和@Table注解
 *
 * @param topLevelClass
 * @param introspectedTable
 */
private void processEntityClass(TopLevelClass topLevelClass, IntrospectedTable introspectedTable) {
    //引入JPA注解
    topLevelClass.addImportedType("javax.persistence.*");
    String tableName = introspectedTable.getFullyQualifiedTableNameAtRuntime();
    //如果包含空格,或者需要分隔符,需要完善
    if (StringUtility.stringContainsSpace(tableName)) {
        tableName = context.getBeginningDelimiter()
                + tableName
                + context.getEndingDelimiter();
    }
    //是否忽略大小写,对于区分大小写的数据库,会有用
    if (caseSensitive && !topLevelClass.getType().getShortName().equals(tableName)) {
        topLevelClass.addAnnotation("@Table(name = \"" + getDelimiterName(tableName) + "\")");
    } else if (!topLevelClass.getType().getShortName().equalsIgnoreCase(tableName)) {
        topLevelClass.addAnnotation("@Table(name = \"" + getDelimiterName(tableName) + "\")");
    } else if (StringUtility.stringHasValue(schema)
            || StringUtility.stringHasValue(beginningDelimiter)
            || StringUtility.stringHasValue(endingDelimiter)) {
        topLevelClass.addAnnotation("@Table(name = \"" + getDelimiterName(tableName) + "\")");
    }
}
 
开发者ID:godlike110,项目名称:tk-mybatis,代码行数:28,代码来源:MapperPlugin.java

示例2: generateServiceImpl

import org.mybatis.generator.api.dom.java.TopLevelClass; //导入方法依赖的package包/类
private GeneratedJavaFile generateServiceImpl(IntrospectedTable table) {
    FullyQualifiedJavaType entityType = new FullyQualifiedJavaType(table.getBaseRecordType());
    FullyQualifiedJavaType primaryType = table.getPrimaryKeyColumns().get(0).getFullyQualifiedJavaType();
    String domainObjectName = table.getFullyQualifiedTable().getDomainObjectName();
    String service = targetPackage + "." + domainObjectName + "Service";
    String serviceImpl = targetPackage + ".impl." + domainObjectName + "ServiceImpl";
    TopLevelClass clazz = new TopLevelClass(new FullyQualifiedJavaType(serviceImpl));
    clazz.addImportedType(new FullyQualifiedJavaType(baseServiceImpl));
    clazz.addImportedType(entityType);
    clazz.addImportedType(new FullyQualifiedJavaType(service));
    clazz.addImportedType(new FullyQualifiedJavaType("org.springframework.stereotype.Service"));
    clazz.addAnnotation("@Service(\"" + firstLetterLowerCase(domainObjectName + "Service") + "\")");
    clazz.setVisibility(JavaVisibility.PUBLIC);
    clazz.setSuperClass(new FullyQualifiedJavaType(
            baseServiceImpl + "<" + entityType.getShortName() + "," + primaryType.getShortName() + ">"));
    clazz.addSuperInterface(new FullyQualifiedJavaType(service));
    ElementHelper.addAuthorTag(clazz, false);
    return new GeneratedJavaFile(clazz, targetProject, new DefaultJavaFormatter());
}
 
开发者ID:drtrang,项目名称:mybatis-generator-extension,代码行数:20,代码来源:ServicePlugin.java

示例3: processEntityClass

import org.mybatis.generator.api.dom.java.TopLevelClass; //导入方法依赖的package包/类
/**
 * 处理实体类的包和@Table注解
 *
 * @param topLevelClass
 * @param introspectedTable
 */
private void processEntityClass(TopLevelClass topLevelClass, IntrospectedTable introspectedTable) {
    //引入JPA注解
    topLevelClass.addImportedType("javax.persistence.*");
    String tableName = introspectedTable.getFullyQualifiedTableNameAtRuntime();
    //如果包含空格,或者需要分隔符,需要完善
    if (StringUtility.stringContainsSpace(tableName)) {
        tableName = context.getBeginningDelimiter()
                + tableName
                + context.getEndingDelimiter();
    }
    //是否忽略大小写,对于区分大小写的数据库,会有用
    if (caseSensitive && !topLevelClass.getType().getShortName().equals(tableName)) {
        topLevelClass.addAnnotation("@Table(name = \"" + getDelimiterName(tableName) + "\")");
    } else if (!topLevelClass.getType().getShortName().equalsIgnoreCase(tableName)) {
        topLevelClass.addAnnotation("@Table(name = \"" + getDelimiterName(tableName) + "\")");
    } else if (StringUtility.stringHasValue(schema)
            || StringUtility.stringHasValue(beginningDelimiter)
            || StringUtility.stringHasValue(endingDelimiter)) {
        topLevelClass.addAnnotation("@Table(name = \"" + getDelimiterName(tableName) + "\")");
    }
    //是否添加apiModelProperty
    if(apiModelProperty){
        topLevelClass.addAnnotation("@ApiModel(value=\""
                +introspectedTable.getRemarks()+"\")");
    }
}
 
开发者ID:Yanweichen,项目名称:MybatisGeneatorUtil,代码行数:33,代码来源:MapperPlugin.java

示例4: modelBaseRecordClassGenerated

import org.mybatis.generator.api.dom.java.TopLevelClass; //导入方法依赖的package包/类
@Override
public boolean modelBaseRecordClassGenerated(TopLevelClass topLevelClass, IntrospectedTable introspectedTable) {
    for (LombokEnum lombok : LOMBOK_ENUMS) {
        topLevelClass.addImportedType(lombok.importedType);
        topLevelClass.addAnnotation(lombok.annotation);
    }

    return true;
}
 
开发者ID:dongfg,项目名称:mybatis-generator-lombok-plugin,代码行数:10,代码来源:LombokPlugin.java

示例5: modelBaseRecordClassGenerated

import org.mybatis.generator.api.dom.java.TopLevelClass; //导入方法依赖的package包/类
@Override
public boolean modelBaseRecordClassGenerated(TopLevelClass topLevelClass, IntrospectedTable introspectedTable) {
    for (LombokEnum lombok : lombokEnums) {
        topLevelClass.addImportedType(lombok.importedType);
        topLevelClass.addAnnotation(lombok.annotation);
    }

    return true;
}
 
开发者ID:drtrang,项目名称:mybatis-generator-extension,代码行数:10,代码来源:LombokPlugin.java

示例6: addModelClassComment

import org.mybatis.generator.api.dom.java.TopLevelClass; //导入方法依赖的package包/类
@Override
public void addModelClassComment(TopLevelClass topLevelClass, IntrospectedTable introspectedTable) {
	topLevelClass.getMethods();
	topLevelClass.addImportedType("lombok.Getter");
	topLevelClass.addImportedType("lombok.Setter");
	topLevelClass.addImportedType("lombok.ToString");
	topLevelClass.addAnnotation("@Getter");
	topLevelClass.addAnnotation("@Setter");
	topLevelClass.addAnnotation("@ToString");
}
 
开发者ID:RuanHR,项目名称:Spring-Boot-Generater,代码行数:11,代码来源:CustomCommentGenerator.java

示例7: getCompilationUnits

import org.mybatis.generator.api.dom.java.TopLevelClass; //导入方法依赖的package包/类
@Override
public List<CompilationUnit> getCompilationUnits() {
    FullyQualifiedTable table = introspectedTable.getFullyQualifiedTable();
    progressCallback.startTask(getString("Progress.8", table.toString())); //$NON-NLS-1$
    Plugin plugins = context.getPlugins();
    CommentGenerator commentGenerator = context.getCommentGenerator();

    FullyQualifiedJavaType type = new FullyQualifiedJavaType(
            introspectedTable.getBaseRecordType());
    TopLevelClass topLevelClass = new TopLevelClass(type);
    topLevelClass.setVisibility(JavaVisibility.PUBLIC);
    commentGenerator.addJavaFileComment(topLevelClass);

    FullyQualifiedJavaType superClass = getSuperClass();
    if (superClass != null) {
        topLevelClass.setSuperClass(superClass);
        topLevelClass.addImportedType(superClass);
    }


    // 注解
    topLevelClass.addAnnotation("@Data");

    // import
    topLevelClass.addImportedType("lombok.Data");

    commentGenerator.addModelClassComment(topLevelClass, introspectedTable);
    
    List<IntrospectedColumn> introspectedColumns = introspectedTable.getAllColumns();

    if (introspectedTable.isConstructorBased()) {
        addParameterizedConstructor(topLevelClass);

        if (!introspectedTable.isImmutable()) {
            addDefaultConstructor(topLevelClass);
        }
    }

    String rootClass = getRootClass();
    for (IntrospectedColumn introspectedColumn : introspectedColumns) {
        if (RootClassInfo.getInstance(rootClass, warnings)
                .containsProperty(introspectedColumn)) {
            continue;
        }

        Field field = getJavaBeansField(introspectedColumn, context, introspectedTable);
        if (plugins.modelFieldGenerated(field, topLevelClass,
                introspectedColumn, introspectedTable,
                Plugin.ModelClassType.BASE_RECORD)) {
            topLevelClass.addField(field);
            topLevelClass.addImportedType(field.getType());
        }

        // 去掉getter setter 方法,使用 lombok

       /* Method method = getJavaBeansGetter(introspectedColumn, context, introspectedTable);
        if (plugins.modelGetterMethodGenerated(method, topLevelClass,
                introspectedColumn, introspectedTable,
                Plugin.ModelClassType.BASE_RECORD)) {
            topLevelClass.addMethod(method);
        }

        if (!introspectedTable.isImmutable()) {
            method = getJavaBeansSetter(introspectedColumn, context, introspectedTable);
            if (plugins.modelSetterMethodGenerated(method, topLevelClass,
                    introspectedColumn, introspectedTable,
                    Plugin.ModelClassType.BASE_RECORD)) {
                topLevelClass.addMethod(method);
            }
        }*/
    }

    List<CompilationUnit> answer = new ArrayList<CompilationUnit>();
    if (context.getPlugins().modelBaseRecordClassGenerated(topLevelClass,
            introspectedTable)) {
        answer.add(topLevelClass);
    }
    return answer;
}
 
开发者ID:nextyu,项目名称:summer-mybatis-generator,代码行数:80,代码来源:SimpleModelGenerator.java


注:本文中的org.mybatis.generator.api.dom.java.TopLevelClass.addAnnotation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。