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


Java TopLevelClass类代码示例

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


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

示例1: addParameterizedConstructor

import org.mybatis.generator.api.dom.java.TopLevelClass; //导入依赖的package包/类
private void addParameterizedConstructor(TopLevelClass topLevelClass) {
    Method method = new Method();
    method.setVisibility(JavaVisibility.PUBLIC);
    method.setConstructor(true);
    method.setName(topLevelClass.getType().getShortName());
    context.getCommentGenerator().addGeneralMethodComment(method, introspectedTable);
    
    StringBuilder sb = new StringBuilder();
    for (IntrospectedColumn introspectedColumn : introspectedTable
            .getPrimaryKeyColumns()) {
        method.addParameter(new Parameter(introspectedColumn.getFullyQualifiedJavaType(),
                introspectedColumn.getJavaProperty()));
        sb.setLength(0);
        sb.append("this."); //$NON-NLS-1$
        sb.append(introspectedColumn.getJavaProperty());
        sb.append(" = "); //$NON-NLS-1$
        sb.append(introspectedColumn.getJavaProperty());
        sb.append(';');
        method.addBodyLine(sb.toString());
    }
    
    topLevelClass.addMethod(method);
}
 
开发者ID:xiachengwei5,项目名称:org.mybatis.generator.core-1.3.5,代码行数:24,代码来源:PrimaryKeyGenerator.java

示例2: addImplementationElements

import org.mybatis.generator.api.dom.java.TopLevelClass; //导入依赖的package包/类
@Override
public void addImplementationElements(TopLevelClass topLevelClass) {
    Set<FullyQualifiedJavaType> importedTypes = new TreeSet<FullyQualifiedJavaType>();
    Method method = getMethodShell(importedTypes);

    if (generateForJava5) {
        method.addSuppressTypeWarningsAnnotation();
    }

    StringBuilder sb = new StringBuilder();
    sb.append(method.getReturnType().getShortName());
    sb.append(" list = "); //$NON-NLS-1$
    sb.append(daoTemplate.getQueryForListMethod(introspectedTable
            .getIbatis2SqlMapNamespace(), introspectedTable
            .getSelectByExampleWithBLOBsStatementId(), "example")); //$NON-NLS-1$
    method.addBodyLine(sb.toString());
    method.addBodyLine("return list;"); //$NON-NLS-1$

    if (context.getPlugins()
            .clientSelectByExampleWithBLOBsMethodGenerated(method,
                    topLevelClass, introspectedTable)) {
        topLevelClass.addImportedTypes(importedTypes);
        topLevelClass.addMethod(method);
    }
}
 
开发者ID:DomKing,项目名称:springbootWeb,代码行数:26,代码来源:SelectByExampleWithBLOBsMethodGenerator.java

示例3: addImplementationElements

import org.mybatis.generator.api.dom.java.TopLevelClass; //导入依赖的package包/类
@Override
public void addImplementationElements(TopLevelClass topLevelClass) {
    Set<FullyQualifiedJavaType> importedTypes = new TreeSet<FullyQualifiedJavaType>();
    Method method = getMethodShell(importedTypes);

    StringBuilder sb = new StringBuilder();
    sb.append("int rows = "); //$NON-NLS-1$
    sb.append(daoTemplate.getUpdateMethod(introspectedTable
            .getIbatis2SqlMapNamespace(), introspectedTable
            .getUpdateByPrimaryKeySelectiveStatementId(), "record")); //$NON-NLS-1$
    method.addBodyLine(sb.toString());

    method.addBodyLine("return rows;"); //$NON-NLS-1$

    if (context.getPlugins()
            .clientUpdateByPrimaryKeySelectiveMethodGenerated(method,
                    topLevelClass, introspectedTable)) {
        topLevelClass.addImportedTypes(importedTypes);
        topLevelClass.addMethod(method);
    }
}
 
开发者ID:DomKing,项目名称:server-utility,代码行数:22,代码来源:UpdateByPrimaryKeySelectiveMethodGenerator.java

示例4: 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:warlock-china,项目名称:azeroth,代码行数:28,代码来源:CrudSupportPlugin.java

示例5: 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

示例6: addImplementationElements

import org.mybatis.generator.api.dom.java.TopLevelClass; //导入依赖的package包/类
@Override
public void addImplementationElements(TopLevelClass topLevelClass) {
    Set<FullyQualifiedJavaType> importedTypes = new TreeSet<FullyQualifiedJavaType>();
    Method method = getMethodShell(importedTypes);

    method
            .addBodyLine("UpdateByExampleParms parms = new UpdateByExampleParms(record, example);"); //$NON-NLS-1$

    StringBuilder sb = new StringBuilder();

    sb.append("int rows = "); //$NON-NLS-1$

    sb.append(daoTemplate.getUpdateMethod(introspectedTable
            .getIbatis2SqlMapNamespace(), introspectedTable
            .getUpdateByExampleSelectiveStatementId(), "parms")); //$NON-NLS-1$
    method.addBodyLine(sb.toString());

    method.addBodyLine("return rows;"); //$NON-NLS-1$

    if (context.getPlugins()
            .clientUpdateByExampleSelectiveMethodGenerated(method,
                    topLevelClass, introspectedTable)) {
        topLevelClass.addImportedTypes(importedTypes);
        topLevelClass.addMethod(method);
    }
}
 
开发者ID:bandaotixi,项目名称:generator_mybatis,代码行数:27,代码来源:UpdateByExampleSelectiveMethodGenerator.java

示例7: modelPrimaryKeyClassGenerated

import org.mybatis.generator.api.dom.java.TopLevelClass; //导入依赖的package包/类
@Override
public boolean modelPrimaryKeyClassGenerated(TopLevelClass topLevelClass,
        IntrospectedTable introspectedTable) {
    generateEquals(topLevelClass, introspectedTable.getPrimaryKeyColumns(),
            introspectedTable);
    generateHashCode(topLevelClass, introspectedTable
            .getPrimaryKeyColumns(), introspectedTable);

    return true;
}
 
开发者ID:bandaotixi,项目名称:generator_mybatis,代码行数:11,代码来源:EqualsHashCodePlugin.java

示例8: generateToString

import org.mybatis.generator.api.dom.java.TopLevelClass; //导入依赖的package包/类
private void generateToString(IntrospectedTable introspectedTable,
        TopLevelClass topLevelClass) {
    Method method = new Method();
    method.setVisibility(JavaVisibility.PUBLIC);
    method.setReturnType(FullyQualifiedJavaType.getStringInstance());
    method.setName("toString"); //$NON-NLS-1$
    if (introspectedTable.isJava5Targeted()) {
        method.addAnnotation("@Override"); //$NON-NLS-1$
    }

    context.getCommentGenerator().addGeneralMethodComment(method,
            introspectedTable);

    method.addBodyLine("StringBuilder sb = new StringBuilder();"); //$NON-NLS-1$
    method.addBodyLine("sb.append(getClass().getSimpleName());"); //$NON-NLS-1$
    method.addBodyLine("sb.append(\" [\");"); //$NON-NLS-1$
    method.addBodyLine("sb.append(\"Hash = \").append(hashCode());"); //$NON-NLS-1$
    StringBuilder sb = new StringBuilder();
    for (Field field : topLevelClass.getFields()) {
        String property = field.getName();
        sb.setLength(0);
        sb.append("sb.append(\"").append(", ").append(property) //$NON-NLS-1$ //$NON-NLS-2$
                .append("=\")").append(".append(").append(property) //$NON-NLS-1$ //$NON-NLS-2$
                .append(");"); //$NON-NLS-1$
        method.addBodyLine(sb.toString());
    }

    method.addBodyLine("sb.append(\"]\");"); //$NON-NLS-1$
    if (useToStringFromRoot && topLevelClass.getSuperClass() != null) {
        method.addBodyLine("sb.append(\", from super class \");"); //$NON-NLS-1$
        method.addBodyLine("sb.append(super.toString());"); //$NON-NLS-1$
    }
    method.addBodyLine("return sb.toString();"); //$NON-NLS-1$

    topLevelClass.addMethod(method);
}
 
开发者ID:nextyu,项目名称:summer-mybatis-generator,代码行数:37,代码来源:ToStringPlugin.java

示例9: generateToString

import org.mybatis.generator.api.dom.java.TopLevelClass; //导入依赖的package包/类
private void generateToString(IntrospectedTable introspectedTable, TopLevelClass topLevelClass) {
        Method method = new Method();
        method.setVisibility(JavaVisibility.PUBLIC);
        method.setReturnType(FullyQualifiedJavaType.getStringInstance());
        method.setName("toString");
        if(introspectedTable.isJava5Targeted()) {
            method.addAnnotation("@Override");
        }

        this.context.getCommentGenerator().addGeneralMethodComment(method, introspectedTable);
        method.addBodyLine("StringBuilder sb = new StringBuilder();");
        method.addBodyLine("sb.append(getClass().getSimpleName());");
        method.addBodyLine("sb.append(\" [\");");
//        method.addBodyLine("sb.append(\"Hash = \").append(hashCode());");
        StringBuilder sb = new StringBuilder();
        Iterator var5 = topLevelClass.getFields().iterator();

        while(var5.hasNext()) {
            Field field = (Field)var5.next();
            String property = field.getName();
            sb.setLength(0);
            sb.append("sb.append(\"").append(", ").append(property).append("=\")").append(".append(").append(property).append(");");
            method.addBodyLine(sb.toString());
        }

        method.addBodyLine("sb.append(\"]\");");
//        if(this.useToStringFromRoot && topLevelClass.getSuperClass() != null) {
//            method.addBodyLine("sb.append(\", from super class \");");
//            method.addBodyLine("sb.append(super.toString());");
//        }

        method.addBodyLine("return sb.toString();");
        topLevelClass.addMethod(method);
    }
 
开发者ID:ychaoyang,项目名称:autotest,代码行数:35,代码来源:ToStringPlugin.java

示例10: addUpdateByPrimaryKeyWithoutBLOBsMethod

import org.mybatis.generator.api.dom.java.TopLevelClass; //导入依赖的package包/类
protected void addUpdateByPrimaryKeyWithoutBLOBsMethod(
        TopLevelClass topLevelClass, Interface interfaze) {
    if (introspectedTable.getRules()
            .generateUpdateByPrimaryKeyWithoutBLOBs()) {
        AbstractDAOElementGenerator methodGenerator = new UpdateByPrimaryKeyWithoutBLOBsMethodGenerator();
        initializeAndExecuteGenerator(methodGenerator, topLevelClass,
                interfaze);
    }
}
 
开发者ID:Yanweichen,项目名称:MybatisGeneatorUtil,代码行数:10,代码来源:DAOGenerator.java

示例11: clientUpdateByExampleSelectiveMethodGenerated

import org.mybatis.generator.api.dom.java.TopLevelClass; //导入依赖的package包/类
public boolean clientUpdateByExampleSelectiveMethodGenerated(Method method,
        TopLevelClass topLevelClass, IntrospectedTable introspectedTable) {
    boolean rc = true;

    for (Plugin plugin : plugins) {
        if (!plugin.clientUpdateByExampleSelectiveMethodGenerated(method,
                topLevelClass, introspectedTable)) {
            rc = false;
            break;
        }
    }

    return rc;
}
 
开发者ID:xiachengwei5,项目名称:org.mybatis.generator.core-1.3.5,代码行数:15,代码来源:PluginAggregator.java

示例12: clientDeleteByPrimaryKeyMethodGenerated

import org.mybatis.generator.api.dom.java.TopLevelClass; //导入依赖的package包/类
public boolean clientDeleteByPrimaryKeyMethodGenerated(Method method,
        TopLevelClass topLevelClass, IntrospectedTable introspectedTable) {
    boolean rc = true;

    for (Plugin plugin : plugins) {
        if (!plugin.clientDeleteByPrimaryKeyMethodGenerated(method,
                topLevelClass, introspectedTable)) {
            rc = false;
            break;
        }
    }

    return rc;
}
 
开发者ID:DomKing,项目名称:springbootWeb,代码行数:15,代码来源:PluginAggregator.java

示例13: providerSelectByExampleWithoutBLOBsMethodGenerated

import org.mybatis.generator.api.dom.java.TopLevelClass; //导入依赖的package包/类
public boolean providerSelectByExampleWithoutBLOBsMethodGenerated(
        Method method, TopLevelClass topLevelClass,
        IntrospectedTable introspectedTable) {
    boolean rc = true;

    for (Plugin plugin : plugins) {
        if (!plugin.providerSelectByExampleWithoutBLOBsMethodGenerated(method,
                topLevelClass, introspectedTable)) {
            rc = false;
            break;
        }
    }

    return rc;
}
 
开发者ID:DomKing,项目名称:springbootWeb,代码行数:16,代码来源:PluginAggregator.java

示例14: addUpdateByExampleWithoutBLOBsMethod

import org.mybatis.generator.api.dom.java.TopLevelClass; //导入依赖的package包/类
protected void addUpdateByExampleWithoutBLOBsMethod(
        TopLevelClass topLevelClass, Interface interfaze) {
    if (introspectedTable.getRules().generateUpdateByExampleWithoutBLOBs()) {
        AbstractDAOElementGenerator methodGenerator = new UpdateByExampleWithoutBLOBsMethodGenerator();
        initializeAndExecuteGenerator(methodGenerator, topLevelClass,
                interfaze);
    }
}
 
开发者ID:bandaotixi,项目名称:generator_mybatis,代码行数:9,代码来源:DAOGenerator.java

示例15: clientSelectAllMethodGenerated

import org.mybatis.generator.api.dom.java.TopLevelClass; //导入依赖的package包/类
@Override
public boolean clientSelectAllMethodGenerated(Method method,
        TopLevelClass topLevelClass, IntrospectedTable introspectedTable) {
    boolean rc = true;

    for (Plugin plugin : plugins) {
        if (!plugin.clientSelectAllMethodGenerated(method,
                topLevelClass, introspectedTable)) {
            rc = false;
            break;
        }
    }

    return rc;
}
 
开发者ID:nextyu,项目名称:summer-mybatis-generator,代码行数:16,代码来源:PluginAggregator.java


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