use of org.mybatis.generator.api.dom.java.Parameter in project generator by mybatis.
the class TestResourceGenerator method simpleInterfaceWithGeneratedAndCustomItems.
public static String simpleInterfaceWithGeneratedAndCustomItems() {
Interface itf = new Interface(new FullyQualifiedJavaType("org.mybatis.test.SimpleInterface"));
itf.setVisibility(JavaVisibility.PUBLIC);
Method method = new Method("subtract");
method.addParameter(new Parameter(FullyQualifiedJavaType.getIntInstance(), "a"));
method.addParameter(new Parameter(FullyQualifiedJavaType.getIntInstance(), "b"));
method.setReturnType(FullyQualifiedJavaType.getIntInstance());
commentGenerator.addMethodComment(method);
itf.addMethod(method);
method = new Method("nonGeneratedMethod");
method.setReturnType(FullyQualifiedJavaType.getIntInstance());
itf.addMethod(method);
return itf.getFormattedContent();
}
use of org.mybatis.generator.api.dom.java.Parameter in project generator by mybatis.
the class InsertMethodGenerator method getMethodShell.
private Method getMethodShell(Set<FullyQualifiedJavaType> importedTypes) {
Method method = new Method();
FullyQualifiedJavaType returnType;
if (introspectedTable.getGeneratedKey() != null) {
IntrospectedColumn introspectedColumn = introspectedTable.getColumn(introspectedTable.getGeneratedKey().getColumn());
if (introspectedColumn == null) {
// the specified column doesn't exist, so don't do the generated
// key
// (the warning has already been reported)
returnType = null;
} else {
returnType = introspectedColumn.getFullyQualifiedJavaType();
importedTypes.add(returnType);
}
} else {
returnType = null;
}
method.setReturnType(returnType);
method.setVisibility(JavaVisibility.PUBLIC);
DAOMethodNameCalculator methodNameCalculator = getDAOMethodNameCalculator();
method.setName(methodNameCalculator.getInsertMethodName(introspectedTable));
FullyQualifiedJavaType parameterType = introspectedTable.getRules().calculateAllFieldsClass();
importedTypes.add(parameterType);
//$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 InsertSelectiveMethodGenerator method getMethodShell.
private Method getMethodShell(Set<FullyQualifiedJavaType> importedTypes) {
Method method = new Method();
FullyQualifiedJavaType returnType;
if (introspectedTable.getGeneratedKey() != null) {
IntrospectedColumn introspectedColumn = introspectedTable.getColumn(introspectedTable.getGeneratedKey().getColumn());
if (introspectedColumn == null) {
// the specified column doesn't exist, so don't do the generated
// key
// (the warning has already been reported)
returnType = null;
} else {
returnType = introspectedColumn.getFullyQualifiedJavaType();
importedTypes.add(returnType);
}
} else {
returnType = null;
}
method.setReturnType(returnType);
method.setVisibility(JavaVisibility.PUBLIC);
method.setName(getDAOMethodNameCalculator().getInsertSelectiveMethodName(introspectedTable));
FullyQualifiedJavaType parameterType = introspectedTable.getRules().calculateAllFieldsClass();
importedTypes.add(parameterType);
//$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 CountByExampleMethodGenerator method getMethodShell.
private Method getMethodShell(Set<FullyQualifiedJavaType> importedTypes) {
FullyQualifiedJavaType type = new FullyQualifiedJavaType(introspectedTable.getExampleType());
importedTypes.add(type);
Method method = new Method();
method.setVisibility(getExampleMethodVisibility());
//$NON-NLS-1$
method.setReturnType(new FullyQualifiedJavaType("long"));
method.setName(getDAOMethodNameCalculator().getCountByExampleMethodName(introspectedTable));
//$NON-NLS-1$
method.addParameter(new Parameter(type, "example"));
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 IbatisDAOTemplate method configureConstructorTemplate.
@Override
protected void configureConstructorTemplate() {
Method method = new Method();
method.setConstructor(true);
method.setVisibility(JavaVisibility.PUBLIC);
//$NON-NLS-1$
method.addParameter(new Parameter(fqjt, "daoManager"));
//$NON-NLS-1$
method.addBodyLine("super(daoManager);");
setConstructorTemplate(method);
}
Aggregations