Search in sources :

Example 26 with Parameter

use of org.mybatis.generator.api.dom.java.Parameter in project generator by mybatis.

the class UpdateByPrimaryKeyWithBLOBsMethodGenerator method getMethodShell.

private Method getMethodShell(Set<FullyQualifiedJavaType> importedTypes) {
    FullyQualifiedJavaType parameterType;
    if (introspectedTable.getRules().generateRecordWithBLOBsClass()) {
        parameterType = new FullyQualifiedJavaType(introspectedTable.getRecordWithBLOBsType());
    } else {
        parameterType = new FullyQualifiedJavaType(introspectedTable.getBaseRecordType());
    }
    importedTypes.add(parameterType);
    Method method = new Method();
    method.setVisibility(JavaVisibility.PUBLIC);
    method.setReturnType(FullyQualifiedJavaType.getIntInstance());
    method.setName(getDAOMethodNameCalculator().getUpdateByPrimaryKeyWithBLOBsMethodName(introspectedTable));
    //$NON-NLS-1$
    method.addParameter(new Parameter(parameterType, "record"));
    for (FullyQualifiedJavaType fqjt : daoTemplate.getCheckedExceptions()) {
        method.addException(fqjt);
        importedTypes.add(fqjt);
    }
    context.getCommentGenerator().addGeneralMethodComment(method, introspectedTable);
    return method;
}
Also used : FullyQualifiedJavaType(org.mybatis.generator.api.dom.java.FullyQualifiedJavaType) Parameter(org.mybatis.generator.api.dom.java.Parameter) Method(org.mybatis.generator.api.dom.java.Method)

Example 27 with Parameter

use of org.mybatis.generator.api.dom.java.Parameter in project generator by mybatis.

the class AbstractDAOTemplate method getMethodClones.

/**
     * Gets the method clones.
     *
     * @param commentGenerator
     *            the comment generator
     * @param introspectedTable
     *            the introspected table
     * @return the method clones
     */
public final List<Method> getMethodClones(CommentGenerator commentGenerator, IntrospectedTable introspectedTable) {
    configure();
    List<Method> answer = new ArrayList<Method>();
    for (Method oldMethod : methods) {
        Method method = new Method();
        for (String bodyLine : oldMethod.getBodyLines()) {
            method.addBodyLine(bodyLine);
        }
        for (FullyQualifiedJavaType fqjt : oldMethod.getExceptions()) {
            method.addException(fqjt);
        }
        for (Parameter parm : oldMethod.getParameters()) {
            method.addParameter(parm);
        }
        method.setConstructor(oldMethod.isConstructor());
        method.setFinal(oldMethod.isFinal());
        method.setStatic(oldMethod.isStatic());
        method.setName(oldMethod.getName());
        method.setReturnType(oldMethod.getReturnType());
        method.setVisibility(oldMethod.getVisibility());
        commentGenerator.addGeneralMethodComment(method, introspectedTable);
        answer.add(method);
    }
    return answer;
}
Also used : FullyQualifiedJavaType(org.mybatis.generator.api.dom.java.FullyQualifiedJavaType) ArrayList(java.util.ArrayList) Parameter(org.mybatis.generator.api.dom.java.Parameter) Method(org.mybatis.generator.api.dom.java.Method)

Example 28 with Parameter

use of org.mybatis.generator.api.dom.java.Parameter in project generator by mybatis.

the class AbstractDAOTemplate method getConstructorClone.

/**
     * Gets the constructor clone.
     *
     * @param commentGenerator
     *            the comment generator
     * @param type
     *            the type
     * @param introspectedTable
     *            the introspected table
     * @return the constructor clone
     */
public final Method getConstructorClone(CommentGenerator commentGenerator, FullyQualifiedJavaType type, IntrospectedTable introspectedTable) {
    configure();
    Method answer = new Method();
    answer.setConstructor(true);
    answer.setName(type.getShortName());
    answer.setVisibility(constructorTemplate.getVisibility());
    for (Parameter parm : constructorTemplate.getParameters()) {
        answer.addParameter(parm);
    }
    for (String bodyLine : constructorTemplate.getBodyLines()) {
        answer.addBodyLine(bodyLine);
    }
    for (FullyQualifiedJavaType fqjt : constructorTemplate.getExceptions()) {
        answer.addException(fqjt);
    }
    commentGenerator.addGeneralMethodComment(answer, introspectedTable);
    return answer;
}
Also used : FullyQualifiedJavaType(org.mybatis.generator.api.dom.java.FullyQualifiedJavaType) Parameter(org.mybatis.generator.api.dom.java.Parameter) Method(org.mybatis.generator.api.dom.java.Method)

Example 29 with Parameter

use of org.mybatis.generator.api.dom.java.Parameter in project generator by mybatis.

the class GenericCIDAOTemplate method configureConstructorTemplate.

@Override
protected void configureConstructorTemplate() {
    Method constructor = new Method();
    constructor.setConstructor(true);
    constructor.setVisibility(JavaVisibility.PUBLIC);
    constructor.addParameter(//$NON-NLS-1$
    new Parameter(sqlMapClientType, "sqlMapClient"));
    //$NON-NLS-1$
    constructor.addBodyLine("super();");
    //$NON-NLS-1$
    constructor.addBodyLine("this.sqlMapClient = sqlMapClient;");
    setConstructorTemplate(constructor);
}
Also used : Parameter(org.mybatis.generator.api.dom.java.Parameter) Method(org.mybatis.generator.api.dom.java.Method)

Example 30 with Parameter

use of org.mybatis.generator.api.dom.java.Parameter in project generator by mybatis.

the class GenericSIDAOTemplate method configureMethods.

@Override
protected void configureMethods() {
    Method method = new Method();
    method.setVisibility(JavaVisibility.PUBLIC);
    //$NON-NLS-1$
    method.setName("setSqlMapClient");
    //$NON-NLS-1$
    method.addParameter(new Parameter(sqlMapClientType, "sqlMapClient"));
    //$NON-NLS-1$
    method.addBodyLine("this.sqlMapClient = sqlMapClient;");
    addMethod(method);
    method = new Method();
    method.setVisibility(JavaVisibility.PUBLIC);
    //$NON-NLS-1$
    method.setName("getSqlMapClient");
    method.setReturnType(sqlMapClientType);
    //$NON-NLS-1$
    method.addBodyLine("return sqlMapClient;");
    addMethod(method);
}
Also used : Parameter(org.mybatis.generator.api.dom.java.Parameter) Method(org.mybatis.generator.api.dom.java.Method)

Aggregations

Parameter (org.mybatis.generator.api.dom.java.Parameter)67 Method (org.mybatis.generator.api.dom.java.Method)66 FullyQualifiedJavaType (org.mybatis.generator.api.dom.java.FullyQualifiedJavaType)54 TreeSet (java.util.TreeSet)20 IntrospectedColumn (org.mybatis.generator.api.IntrospectedColumn)17 Field (org.mybatis.generator.api.dom.java.Field)11 ArrayList (java.util.ArrayList)7 InnerClass (org.mybatis.generator.api.dom.java.InnerClass)5 TopLevelClass (org.mybatis.generator.api.dom.java.TopLevelClass)5 Messages.getString (org.mybatis.generator.internal.util.messages.Messages.getString)4 CompilationUnit (org.mybatis.generator.api.dom.java.CompilationUnit)3 CommentGenerator (org.mybatis.generator.api.CommentGenerator)2 FullyQualifiedTable (org.mybatis.generator.api.FullyQualifiedTable)2 Interface (org.mybatis.generator.api.dom.java.Interface)2 DAOMethodNameCalculator (org.mybatis.generator.api.DAOMethodNameCalculator)1 Rules (org.mybatis.generator.internal.rules.Rules)1