Search in sources :

Example 66 with Parameter

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

the class RowBoundsPlugin method copyAndAddMethod.

/**
     * Use the method copy constructor to create a new method, then
     * add the rowBounds parameter.
     * 
     * @param fullyQualifiedTable
     * @param method
     */
private void copyAndAddMethod(Method method, Interface interfaze) {
    Method newMethod = new Method(method);
    //$NON-NLS-1$
    newMethod.setName(method.getName() + "WithRowbounds");
    //$NON-NLS-1$
    newMethod.addParameter(new Parameter(rowBounds, "rowBounds"));
    interfaze.addMethod(newMethod);
    interfaze.addImportedType(rowBounds);
}
Also used : Parameter(org.mybatis.generator.api.dom.java.Parameter) Method(org.mybatis.generator.api.dom.java.Method)

Example 67 with Parameter

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

the class JavaBeansUtil method getJavaBeansSetter.

/**
     * Gets the java beans setter.
     *
     * @param introspectedColumn
     *            the introspected column
     * @param context
     *            the context
     * @param introspectedTable
     *            the introspected table
     * @return the java beans setter
     */
public static Method getJavaBeansSetter(IntrospectedColumn introspectedColumn, Context context, IntrospectedTable introspectedTable) {
    FullyQualifiedJavaType fqjt = introspectedColumn.getFullyQualifiedJavaType();
    String property = introspectedColumn.getJavaProperty();
    Method method = new Method();
    method.setVisibility(JavaVisibility.PUBLIC);
    method.setName(getSetterMethodName(property));
    method.addParameter(new Parameter(fqjt, property));
    context.getCommentGenerator().addSetterComment(method, introspectedTable, introspectedColumn);
    StringBuilder sb = new StringBuilder();
    if (introspectedColumn.isStringColumn() && isTrimStringsEnabled(introspectedColumn)) {
        //$NON-NLS-1$
        sb.append("this.");
        sb.append(property);
        //$NON-NLS-1$
        sb.append(" = ");
        sb.append(property);
        //$NON-NLS-1$
        sb.append(" == null ? null : ");
        sb.append(property);
        //$NON-NLS-1$
        sb.append(".trim();");
        method.addBodyLine(sb.toString());
    } else {
        //$NON-NLS-1$
        sb.append("this.");
        sb.append(property);
        //$NON-NLS-1$
        sb.append(" = ");
        sb.append(property);
        sb.append(';');
        method.addBodyLine(sb.toString());
    }
    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)

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