Java Code Examples for org.mybatis.generator.api.dom.java.Method#addJavaDocLine()

The following examples show how to use org.mybatis.generator.api.dom.java.Method#addJavaDocLine() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DGCommentGenerator.java    From mybatis-generator-core-fix with Apache License 2.0 6 votes vote down vote up
@Override
public void addGetterComment(Method method, IntrospectedTable introspectedTable, IntrospectedColumn introspectedColumn) {
    // get方法注释
    StringBuffer sb = new StringBuffer();
    method.addJavaDocLine("/**");
    method.addJavaDocLine(" * <pre>");
    method.addJavaDocLine(" * 获取:" + introspectedColumn.getRemarks());
    sb.append(" * 表字段:");
    sb.append(introspectedTable.getFullyQualifiedTable());
    sb.append('.');
    sb.append(introspectedColumn.getActualColumnName());
    method.addJavaDocLine(sb.toString());
    method.addJavaDocLine(" * </pre>");
    method.addJavaDocLine(" *");
    sb = new StringBuffer();
    sb.append(" * @return ");
    sb.append(introspectedTable.getFullyQualifiedTable());
    sb.append('.');
    sb.append(introspectedColumn.getActualColumnName());
    sb.append(":");
    sb.append(introspectedColumn.getRemarks());
    method.addJavaDocLine(sb.toString());
    // addJavadocTag(method, false);
    method.addJavaDocLine(" */");
}
 
Example 2
Source File: CreateGenericInterfacePlugin.java    From mybatis-generator-plugins with Apache License 2.0 6 votes vote down vote up
void addGenericMethod(Method method, FullyQualifiedJavaType returnType, FullyQualifiedJavaType... types) {
	method.addAnnotation("@Override");

	if (!methodsAdded.contains(method.getName())) {
		Method genericMethod = new Method(method.getName());
		genericMethod.addJavaDocLine("/**");
		genericMethod.addJavaDocLine(" * This method was generated by MyBatis Generator.");
		genericMethod.addJavaDocLine(" *");
		genericMethod.addJavaDocLine(" * @mbg.generated");
		genericMethod.addJavaDocLine(" */");

		genericMethod.setReturnType(returnType);

		for (int i = 0; i < method.getParameters().size(); i++) {
			Parameter parameter = method.getParameters().get(i);
			FullyQualifiedJavaType paramType = types.length > i ? types[i] : parameter.getType();

			Parameter genericParameter = new Parameter(paramType, parameter.getName());
			genericMethod.addParameter(genericParameter);
		}

		genericInterface.addMethod(genericMethod);

		methodsAdded.add(method.getName());
	}
}
 
Example 3
Source File: DefaultCommentGenerator.java    From mybatis-generator-plus with Apache License 2.0 6 votes vote down vote up
public void addGeneralMethodComment(Method method,
        IntrospectedTable introspectedTable) {
    if (suppressAllComments) {
        return;
    }

    StringBuilder sb = new StringBuilder();

    method.addJavaDocLine("/**"); //$NON-NLS-1$
    method
            .addJavaDocLine(" * This method was generated by MyBatis Generator."); //$NON-NLS-1$

    sb.append(" * This method corresponds to the database table "); //$NON-NLS-1$
    sb.append(introspectedTable.getFullyQualifiedTable());
    method.addJavaDocLine(sb.toString());

    addJavadocTag(method, false);

    method.addJavaDocLine(" */"); //$NON-NLS-1$
}
 
Example 4
Source File: MyMapperCommentGenerator.java    From jvue-admin with MIT License 6 votes vote down vote up
/**
 * setter方法注释
 *
 * @param method
 * @param introspectedTable
 * @param introspectedColumn
 */
@Override
public void addSetterComment(Method method, IntrospectedTable introspectedTable, IntrospectedColumn introspectedColumn) {
    StringBuilder sb = new StringBuilder();
    method.addJavaDocLine("/**");
    if (StringUtility.stringHasValue(introspectedColumn.getRemarks())) {
        sb.append(" * 设置");
        sb.append(introspectedColumn.getRemarks());
        method.addJavaDocLine(sb.toString());
        method.addJavaDocLine(" *");
    }
    Parameter parm = method.getParameters().get(0);
    sb.setLength(0);
    sb.append(" * @param ");
    sb.append(parm.getName());
    if (StringUtility.stringHasValue(introspectedColumn.getRemarks())) {
        sb.append(" ");
        sb.append(introspectedColumn.getRemarks());
    }
    method.addJavaDocLine(sb.toString());
    method.addJavaDocLine(" */");
}
 
Example 5
Source File: MyMapperCommentGenerator.java    From jvue-admin with MIT License 6 votes vote down vote up
/**
 * getter方法注释
 *
 * @param method
 * @param introspectedTable
 * @param introspectedColumn
 */
@Override
public void addGetterComment(Method method, IntrospectedTable introspectedTable, IntrospectedColumn introspectedColumn) {
    StringBuilder sb = new StringBuilder();
    method.addJavaDocLine("/**");
    if (StringUtility.stringHasValue(introspectedColumn.getRemarks())) {
        sb.append(" * 获取");
        sb.append(introspectedColumn.getRemarks());
        method.addJavaDocLine(sb.toString());
        method.addJavaDocLine(" *");
    }
    sb.setLength(0);
    sb.append(" * @return ");
    sb.append(introspectedColumn.getActualColumnName());
    if (StringUtility.stringHasValue(introspectedColumn.getRemarks())) {
        sb.append(" - ");
        sb.append(introspectedColumn.getRemarks());
    }
    method.addJavaDocLine(sb.toString());
    method.addJavaDocLine(" */");
}
 
Example 6
Source File: DefaultCommentGenerator.java    From mapper-generator-javafx with Apache License 2.0 6 votes vote down vote up
@Override
public void addGeneralMethodComment(Method method,
        IntrospectedTable introspectedTable) {
    if (suppressAllComments) {
        return;
    }

    StringBuilder sb = new StringBuilder();

    method.addJavaDocLine("/**");

    sb.append(introspectedTable.getFullyQualifiedTable());
    method.addJavaDocLine(sb.toString());

    addJavadocTag(method, false);

    method.addJavaDocLine(" */");
}
 
Example 7
Source File: DefaultCommentGenerator.java    From mapper-generator-javafx with Apache License 2.0 5 votes vote down vote up
@Override
public void addSetterComment(Method method,
        IntrospectedTable introspectedTable,
        IntrospectedColumn introspectedColumn) {
    if (suppressAllComments) {
        return;
    }

    StringBuilder sb = new StringBuilder();

    method.addJavaDocLine("/**");

    sb.append(introspectedTable.getFullyQualifiedTable());
    sb.append('.');
    sb.append(introspectedColumn.getActualColumnName());
    method.addJavaDocLine(sb.toString());

    method.addJavaDocLine(" *");

    Parameter parm = method.getParameters().get(0);
    sb.setLength(0);
    sb.append(" * @param ");
    sb.append(parm.getName());
    sb.append(" the value for ");
    sb.append(introspectedTable.getFullyQualifiedTable());
    sb.append('.');
    sb.append(introspectedColumn.getActualColumnName());
    method.addJavaDocLine(sb.toString());

    addJavadocTag(method, false);

    method.addJavaDocLine(" */");
}
 
Example 8
Source File: DefaultCommentGenerator.java    From mapper-generator-javafx with Apache License 2.0 5 votes vote down vote up
@Override
public void addGetterComment(Method method,
        IntrospectedTable introspectedTable,
        IntrospectedColumn introspectedColumn) {
    if (suppressAllComments) {
        return;
    }

    StringBuilder sb = new StringBuilder();

    method.addJavaDocLine("/**");

    sb.append(introspectedTable.getFullyQualifiedTable());
    sb.append('.');
    sb.append(introspectedColumn.getActualColumnName());
    method.addJavaDocLine(sb.toString());

    method.addJavaDocLine(" *");

    sb.setLength(0);
    sb.append(" * @return the value of ");
    sb.append(introspectedTable.getFullyQualifiedTable());
    sb.append('.');
    sb.append(introspectedColumn.getActualColumnName());
    method.addJavaDocLine(sb.toString());

    addJavadocTag(method, false);

    method.addJavaDocLine(" */");
}
 
Example 9
Source File: JavaElementTools.java    From mybatis-generator-plugin with Apache License 2.0 5 votes vote down vote up
/**
 * clone
 * @param method
 * @return
 */
public static Method clone(Method method) {
    Method dest = new Method(method.getName());
    // 注解
    for (String javaDocLine : method.getJavaDocLines()) {
        dest.addJavaDocLine(javaDocLine);
    }
    dest.setReturnType(method.getReturnType());
    for (Parameter parameter : method.getParameters()) {
        dest.addParameter(JavaElementTools.clone(parameter));
    }
    for (FullyQualifiedJavaType exception : method.getExceptions()) {
        dest.addException(exception);
    }
    for (TypeParameter typeParameter : method.getTypeParameters()) {
        dest.addTypeParameter(typeParameter);
    }
    dest.addBodyLines(method.getBodyLines());
    dest.setConstructor(method.isConstructor());
    dest.setNative(method.isNative());
    dest.setSynchronized(method.isSynchronized());
    dest.setDefault(method.isDefault());
    dest.setFinal(method.isFinal());
    dest.setStatic(method.isStatic());
    dest.setVisibility(method.getVisibility());
    return dest;
}
 
Example 10
Source File: DGCommentGenerator.java    From mybatis-generator-core-fix with Apache License 2.0 5 votes vote down vote up
@Override
public void addGeneralMethodComment(Method method, IntrospectedTable introspectedTable) {
    // 生成方法注释
    method.addJavaDocLine("/**");
    String method_name = method.getName();

    if ("deleteByPrimaryKey".equals(method_name)) {
        method.addJavaDocLine(" * 根据主键删除数据库的记录");
    } else if ("insert".equals(method_name)) {
        method.addJavaDocLine(" * 插入数据库记录");
    } else if ("selectByPrimaryKey".equals(method_name)) {
        method.addJavaDocLine(" * 根据主键获取一条数据库记录");
    } else if ("updateByPrimaryKey".equals(method_name)) {
        method.addJavaDocLine(" * 根据主键来更新数据库记录");
    } else if ("selectAll".equals(method_name)) {
        method.addJavaDocLine(" * 获取全部数据库记录");
    }
    method.addJavaDocLine(" *");
    List<Parameter> parameterList = method.getParameters();
    String paramterName;
    for (Parameter parameter : parameterList) {
        paramterName = parameter.getName();
        method.addJavaDocLine(" * @param " + paramterName);
    }
    // addJavadocTag(method, false);
    method.addJavaDocLine(" */");
}
 
Example 11
Source File: MybatisGeneratorPlugin.java    From java-master with Apache License 2.0 5 votes vote down vote up
@Override
public boolean modelGetterMethodGenerated(Method method, TopLevelClass topLevelClass, IntrospectedColumn introspectedColumn,
                                          IntrospectedTable introspectedTable, ModelClassType modelClassType) {
    // 添加entity get方法注释
    String docLine = "/**\n" +
            "     * 获取%s\n" +
            "     */";
    method.addJavaDocLine(String.format(docLine, introspectedColumn.getRemarks()));
    return super.modelGetterMethodGenerated(method, topLevelClass, introspectedColumn, introspectedTable, modelClassType);
}
 
Example 12
Source File: DGCommentGenerator.java    From mybatis-generator-core-fix with Apache License 2.0 5 votes vote down vote up
@Override
public void addSetterComment(Method method, IntrospectedTable introspectedTable, IntrospectedColumn introspectedColumn) {
    // set方法注释
    StringBuffer sb = new StringBuffer();
    method.addJavaDocLine("/**");
    method.addJavaDocLine(" * <pre>");
    method.addJavaDocLine(" * 设置:" + introspectedColumn.getRemarks());
    sb.append(" * 表字段:");
    sb.append(introspectedTable.getFullyQualifiedTable());
    sb.append('.');
    sb.append(introspectedColumn.getActualColumnName());
    method.addJavaDocLine(sb.toString());
    method.addJavaDocLine(" * </pre>");
    method.addJavaDocLine(" *");
    Parameter parm = method.getParameters().get(0);
    method.addJavaDocLine(" * @param " + parm.getName());
    sb = new StringBuffer();
    sb.append(" *            ");
    sb.append(introspectedTable.getFullyQualifiedTable());
    sb.append('.');
    sb.append(introspectedColumn.getActualColumnName());
    sb.append(":");
    sb.append(introspectedColumn.getRemarks());
    method.addJavaDocLine(sb.toString());
    // addJavadocTag(method, false);
    method.addJavaDocLine(" */");
}
 
Example 13
Source File: DG2CommentGenerator.java    From mybatis-generator-core-fix with Apache License 2.0 5 votes vote down vote up
@Override
    public void addGetterComment(Method method,
                                 IntrospectedTable introspectedTable,
                                 IntrospectedColumn introspectedColumn) {
        StringBuilder sb = new StringBuilder();

        method.addJavaDocLine("/**"); //$NON-NLS-1$
//        method.addJavaDocLine(" * This method was generated by MyBatis Generator."); //$NON-NLS-1$

        sb.append(" * 获取 "); //$NON-NLS-1$
        sb.append(introspectedColumn.getRemarks()).append(" 字段:");
        sb.append(introspectedTable.getFullyQualifiedTable());
        sb.append('.');
        sb.append(introspectedColumn.getActualColumnName());
        method.addJavaDocLine(sb.toString());

        method.addJavaDocLine(" *"); //$NON-NLS-1$

        sb.setLength(0);
        sb.append(" * @return "); //$NON-NLS-1$
        sb.append(introspectedTable.getFullyQualifiedTable());
        sb.append('.');
        sb.append(introspectedColumn.getActualColumnName());
        sb.append(", ");
        sb.append(introspectedColumn.getRemarks());
        method.addJavaDocLine(sb.toString());

//        addJavadocTag(method, false);

        method.addJavaDocLine(" */"); //$NON-NLS-1$
    }
 
Example 14
Source File: DG2CommentGenerator.java    From mybatis-generator-core-fix with Apache License 2.0 5 votes vote down vote up
@Override
    public void addSetterComment(Method method,
                                 IntrospectedTable introspectedTable,
                                 IntrospectedColumn introspectedColumn) {

        StringBuilder sb = new StringBuilder();

        method.addJavaDocLine("/**"); //$NON-NLS-1$
//        method.addJavaDocLine(" * This method was generated by MyBatis Generator."); //$NON-NLS-1$

        sb.append(" * 设置 ");  //$NON-NLS-1$
        sb.append(introspectedColumn.getRemarks()).append(" 字段:");
        sb.append(introspectedTable.getFullyQualifiedTable());
        sb.append('.');
        sb.append(introspectedColumn.getActualColumnName());
        method.addJavaDocLine(sb.toString());

        method.addJavaDocLine(" *"); //$NON-NLS-1$

        Parameter parm = method.getParameters().get(0);
        sb.setLength(0);
        sb.append(" * @param "); //$NON-NLS-1$
        sb.append(parm.getName());
        sb.append(" the value for "); //$NON-NLS-1$
        sb.append(introspectedTable.getFullyQualifiedTable());
        sb.append('.');
        sb.append(introspectedColumn.getActualColumnName());
        sb.append(", ");
        sb.append(introspectedColumn.getRemarks());
        method.addJavaDocLine(sb.toString());

//        addJavadocTag(method, false);

        method.addJavaDocLine(" */"); //$NON-NLS-1$
    }
 
Example 15
Source File: DefaultCommentGenerator.java    From mybatis-generator-plus with Apache License 2.0 5 votes vote down vote up
public void addGetterComment(Method method,
        IntrospectedTable introspectedTable,
        IntrospectedColumn introspectedColumn) {
    if (suppressAllComments) {
        return;
    }

    StringBuilder sb = new StringBuilder();

    method.addJavaDocLine("/**"); //$NON-NLS-1$
    method
            .addJavaDocLine(" * This method was generated by MyBatis Generator."); //$NON-NLS-1$

    sb.append(" * This method returns the value of the database column "); //$NON-NLS-1$
    sb.append(introspectedTable.getFullyQualifiedTable());
    sb.append('.');
    sb.append(introspectedColumn.getActualColumnName());
    method.addJavaDocLine(sb.toString());

    method.addJavaDocLine(" *"); //$NON-NLS-1$

    sb.setLength(0);
    sb.append(" * @return the value of "); //$NON-NLS-1$
    sb.append(introspectedTable.getFullyQualifiedTable());
    sb.append('.');
    sb.append(introspectedColumn.getActualColumnName());
    method.addJavaDocLine(sb.toString());

    addJavadocTag(method, false);

    method.addJavaDocLine(" */"); //$NON-NLS-1$
}
 
Example 16
Source File: DefaultCommentGenerator.java    From mybatis-generator-plus with Apache License 2.0 5 votes vote down vote up
public void addSetterComment(Method method,
        IntrospectedTable introspectedTable,
        IntrospectedColumn introspectedColumn) {
    if (suppressAllComments) {
        return;
    }

    StringBuilder sb = new StringBuilder();

    method.addJavaDocLine("/**"); //$NON-NLS-1$
    method
            .addJavaDocLine(" * This method was generated by MyBatis Generator."); //$NON-NLS-1$

    sb.append(" * This method sets the value of the database column "); //$NON-NLS-1$
    sb.append(introspectedTable.getFullyQualifiedTable());
    sb.append('.');
    sb.append(introspectedColumn.getActualColumnName());
    method.addJavaDocLine(sb.toString());

    method.addJavaDocLine(" *"); //$NON-NLS-1$

    Parameter parm = method.getParameters().get(0);
    sb.setLength(0);
    sb.append(" * @param "); //$NON-NLS-1$
    sb.append(parm.getName());
    sb.append(" the value for "); //$NON-NLS-1$
    sb.append(introspectedTable.getFullyQualifiedTable());
    sb.append('.');
    sb.append(introspectedColumn.getActualColumnName());
    method.addJavaDocLine(sb.toString());

    addJavadocTag(method, false);

    method.addJavaDocLine(" */"); //$NON-NLS-1$
}
 
Example 17
Source File: MybatisGeneratorPlugin.java    From java-master with Apache License 2.0 5 votes vote down vote up
@Override
public boolean modelSetterMethodGenerated(Method method, TopLevelClass topLevelClass, IntrospectedColumn introspectedColumn,
                                          IntrospectedTable introspectedTable, ModelClassType modelClassType) {
    // 添加entity set方法注释
    String docLine = "/**\n" +
            "     * 设置%s\n" +
            "     */";
    method.addJavaDocLine(String.format(docLine, introspectedColumn.getRemarks()));
    return super.modelGetterMethodGenerated(method, topLevelClass, introspectedColumn, introspectedTable, modelClassType);
}
 
Example 18
Source File: DG2CommentGenerator.java    From mybatis-generator-core-fix with Apache License 2.0 4 votes vote down vote up
public void addGeneralMethodComment(Method method, IntrospectedTable introspectedTable) {
        StringBuilder sb = new StringBuilder();
        method.addJavaDocLine("/**"); //$NON-NLS-1$
//        method.addJavaDocLine(" * This method was generated by MyBatis Generator."); //$NON-NLS-1$

//        sb.append(" * This method corresponds to the database table "); //$NON-NLS-1$
        sb.append(" * ");
        if (method.isConstructor()) {
            sb.append(" 构造查询条件");
        }
        String method_name = method.getName();
        if ("setOrderByClause".equals(method_name)) {
            sb.append(" 设置排序字段");
        } else if ("setDistinct".equals(method_name)) {
            sb.append(" 设置过滤重复数据");
        } else if ("getOredCriteria".equals(method_name)) {
            sb.append(" 获取当前的查询条件实例");
        } else if ("isDistinct".equals(method_name)) {
            sb.append(" 是否过滤重复数据");
        } else if ("getOrderByClause".equals(method_name)) {
            sb.append(" 获取排序字段");
        } else if ("createCriteria".equals(method_name)) {
            sb.append(" 创建一个查询条件");
        } else if ("createCriteriaInternal".equals(method_name)) {
            sb.append(" 内部构建查询条件对象");
        } else if ("clear".equals(method_name)) {
            sb.append(" 清除查询条件");
        } else if ("countByExample".equals(method_name)) {
            sb.append(" 根据指定的条件获取数据库记录数");
        } else if ("deleteByExample".equals(method_name)) {
            sb.append(" 根据指定的条件删除数据库符合条件的记录");
        } else if ("deleteByPrimaryKey".equals(method_name)) {
            sb.append(" 根据主键删除数据库的记录");
        } else if ("insert".equals(method_name)) {
            sb.append(" 新写入数据库记录");
        } else if ("insertSelective".equals(method_name)) {
            sb.append(" 动态字段,写入数据库记录");
        } else if ("selectByExample".equals(method_name)) {
            sb.append(" 根据指定的条件查询符合条件的数据库记录");
        } else if ("selectByPrimaryKey".equals(method_name)) {
            sb.append(" 根据指定主键获取一条数据库记录");
        } else if ("updateByExampleSelective".equals(method_name)) {
            sb.append(" 动态根据指定的条件来更新符合条件的数据库记录");
        } else if ("updateByExample".equals(method_name)) {
            sb.append(" 根据指定的条件来更新符合条件的数据库记录");
        } else if ("updateByPrimaryKeySelective".equals(method_name)) {
            sb.append(" 动态字段,根据主键来更新符合条件的数据库记录");
        } else if ("updateByPrimaryKey".equals(method_name)) {
            sb.append(" 根据主键来更新符合条件的数据库记录");
        }
        sb.append(",");
        sb.append(introspectedTable.getFullyQualifiedTable());
        method.addJavaDocLine(sb.toString());

        final List<Parameter> parameterList = method.getParameters();
        if (!parameterList.isEmpty()) {
            method.addJavaDocLine(" *");
            if ("or".equals(method_name)) {
                sb.append(" 增加或者的查询条件,用于构建或者查询");
            }
        } else {
            if ("or".equals(method_name)) {
                sb.append(" 创建一个新的或者查询条件");
            }
        }
        String paramterName;
        for (Parameter parameter : parameterList) {
            sb.setLength(0);
            sb.append(" * @param "); //$NON-NLS-1$
            paramterName = parameter.getName();
            sb.append(paramterName);
            if ("orderByClause".equals(paramterName)) {
                sb.append(" 排序字段"); //$NON-NLS-1$
            } else if ("distinct".equals(paramterName)) {
                sb.append(" 是否过滤重复数据");
            } else if ("criteria".equals(paramterName)) {
                sb.append(" 过滤条件实例");
            }
            method.addJavaDocLine(sb.toString());
        }


        //        addJavadocTag(method, false);

        method.addJavaDocLine(" */"); //$NON-NLS-1$
    }