use of org.mybatis.generator.api.dom.java.Parameter in project generator by mybatis.
the class TestResourceGenerator method simpleClassWithGeneratedAndCustomItems.
public static String simpleClassWithGeneratedAndCustomItems() {
TopLevelClass tlc = new TopLevelClass(new FullyQualifiedJavaType("org.mybatis.test.SimpleClass"));
tlc.setVisibility(JavaVisibility.PUBLIC);
Field field = new Field("description", FullyQualifiedJavaType.getStringInstance());
field.setVisibility(JavaVisibility.PRIVATE);
commentGenerator.addFieldComment(field);
tlc.addField(field);
Method method = new Method("getDescription");
method.setReturnType(FullyQualifiedJavaType.getStringInstance());
method.addBodyLine("return description;");
method.setVisibility(JavaVisibility.PUBLIC);
commentGenerator.addMethodComment(method);
tlc.addMethod(method);
method = new Method("setDescription");
method.addParameter(new Parameter(FullyQualifiedJavaType.getStringInstance(), "description"));
method.addBodyLine("this.description = description;");
method.setVisibility(JavaVisibility.PUBLIC);
commentGenerator.addMethodComment(method);
tlc.addMethod(method);
// no comments on these items - they should survive a merge
FullyQualifiedJavaType bigDecimal = new FullyQualifiedJavaType("java.math.BigDecimal");
tlc.addImportedType(bigDecimal);
field = new Field("amount", bigDecimal);
field.setVisibility(JavaVisibility.PRIVATE);
tlc.addField(field);
method = new Method("getAmount");
method.setReturnType(bigDecimal);
method.addBodyLine("return amount;");
method.setVisibility(JavaVisibility.PUBLIC);
tlc.addMethod(method);
method = new Method("setAmount");
method.addParameter(new Parameter(bigDecimal, "amount"));
method.addBodyLine("this.amount = amount;");
method.setVisibility(JavaVisibility.PUBLIC);
tlc.addMethod(method);
return tlc.getFormattedContent();
}
use of org.mybatis.generator.api.dom.java.Parameter in project generator by mybatis.
the class TestResourceGenerator method simpleClassWithAllGeneratedItems.
public static String simpleClassWithAllGeneratedItems() {
TopLevelClass tlc = new TopLevelClass(new FullyQualifiedJavaType("org.mybatis.test.SimpleClass"));
tlc.setVisibility(JavaVisibility.PUBLIC);
Field field = new Field("id", FullyQualifiedJavaType.getIntInstance());
field.setVisibility(JavaVisibility.PRIVATE);
commentGenerator.addFieldComment(field);
tlc.addField(field);
Method method = new Method("getId");
method.setReturnType(FullyQualifiedJavaType.getIntInstance());
method.addBodyLine("return id;");
method.setVisibility(JavaVisibility.PUBLIC);
commentGenerator.addMethodComment(method);
tlc.addMethod(method);
method = new Method("setId");
method.addParameter(new Parameter(FullyQualifiedJavaType.getIntInstance(), "id"));
method.addBodyLine("this.id = id;");
method.setVisibility(JavaVisibility.PUBLIC);
commentGenerator.addMethodComment(method);
tlc.addMethod(method);
return tlc.getFormattedContent();
}
use of org.mybatis.generator.api.dom.java.Parameter in project generator by mybatis.
the class TestResourceGenerator method simpleInterfaceWithAllGeneratedItems.
public static String simpleInterfaceWithAllGeneratedItems() {
Interface itf = new Interface(new FullyQualifiedJavaType("org.mybatis.test.SimpleInterface"));
itf.setVisibility(JavaVisibility.PUBLIC);
Method method = new Method("count");
method.setReturnType(FullyQualifiedJavaType.getIntInstance());
commentGenerator.addMethodComment(method);
itf.addMethod(method);
method = new Method("add");
method.addParameter(new Parameter(FullyQualifiedJavaType.getIntInstance(), "a"));
method.addParameter(new Parameter(FullyQualifiedJavaType.getIntInstance(), "b"));
method.setReturnType(FullyQualifiedJavaType.getIntInstance());
commentGenerator.addMethodComment(method);
itf.addMethod(method);
return itf.getFormattedContent();
}
use of org.mybatis.generator.api.dom.java.Parameter in project generator by mybatis.
the class UpdateByPrimaryKeyWithoutBLOBsMethodGenerator method getMethodShell.
private Method getMethodShell(Set<FullyQualifiedJavaType> importedTypes) {
FullyQualifiedJavaType parameterType = new FullyQualifiedJavaType(introspectedTable.getBaseRecordType());
importedTypes.add(parameterType);
Method method = new Method();
method.setVisibility(JavaVisibility.PUBLIC);
method.setReturnType(FullyQualifiedJavaType.getIntInstance());
method.setName(getDAOMethodNameCalculator().getUpdateByPrimaryKeyWithoutBLOBsMethodName(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;
}
use of org.mybatis.generator.api.dom.java.Parameter in project generator by mybatis.
the class UpdateByExampleSelectiveMethodGenerator method getMethodShell.
private Method getMethodShell(Set<FullyQualifiedJavaType> importedTypes) {
FullyQualifiedJavaType parameterType;
if (introspectedTable.getRules().generateRecordWithBLOBsClass()) {
parameterType = new FullyQualifiedJavaType(introspectedTable.getRecordWithBLOBsType());
} else if (introspectedTable.getRules().generateBaseRecordClass()) {
parameterType = new FullyQualifiedJavaType(introspectedTable.getBaseRecordType());
} else {
parameterType = new FullyQualifiedJavaType(introspectedTable.getPrimaryKeyType());
}
importedTypes.add(parameterType);
Method method = new Method();
method.setVisibility(getExampleMethodVisibility());
method.setReturnType(FullyQualifiedJavaType.getIntInstance());
method.setName(getDAOMethodNameCalculator().getUpdateByExampleSelectiveMethodName(introspectedTable));
//$NON-NLS-1$
method.addParameter(new Parameter(parameterType, "record"));
method.addParameter(new Parameter(new FullyQualifiedJavaType(introspectedTable.getExampleType()), //$NON-NLS-1$
"example"));
for (FullyQualifiedJavaType fqjt : daoTemplate.getCheckedExceptions()) {
method.addException(fqjt);
importedTypes.add(fqjt);
}
context.getCommentGenerator().addGeneralMethodComment(method, introspectedTable);
return method;
}
Aggregations