use of org.mybatis.generator.api.dom.java.FullyQualifiedJavaType in project generator by mybatis.
the class UpdateByExampleParmsInnerclassGenerator method addImplementationElements.
@Override
public void addImplementationElements(TopLevelClass topLevelClass) {
topLevelClass.addImportedType(new FullyQualifiedJavaType(introspectedTable.getExampleType()));
InnerClass innerClass = new InnerClass(new FullyQualifiedJavaType(//$NON-NLS-1$
"UpdateByExampleParms"));
innerClass.setVisibility(JavaVisibility.PROTECTED);
innerClass.setStatic(true);
innerClass.setSuperClass(introspectedTable.getExampleType());
context.getCommentGenerator().addClassComment(innerClass, introspectedTable);
Method method = new Method();
method.setConstructor(true);
method.setVisibility(JavaVisibility.PUBLIC);
method.setName(innerClass.getType().getShortName());
method.addParameter(new Parameter(FullyQualifiedJavaType.getObjectInstance(), //$NON-NLS-1$
"record"));
method.addParameter(new Parameter(new FullyQualifiedJavaType(introspectedTable.getExampleType()), //$NON-NLS-1$
"example"));
//$NON-NLS-1$
method.addBodyLine("super(example);");
//$NON-NLS-1$
method.addBodyLine("this.record = record;");
innerClass.addMethod(method);
Field field = new Field();
field.setVisibility(JavaVisibility.PRIVATE);
field.setType(FullyQualifiedJavaType.getObjectInstance());
//$NON-NLS-1$
field.setName("record");
innerClass.addField(field);
method = new Method();
method.setVisibility(JavaVisibility.PUBLIC);
method.setReturnType(FullyQualifiedJavaType.getObjectInstance());
//$NON-NLS-1$
method.setName("getRecord");
//$NON-NLS-1$
method.addBodyLine("return record;");
innerClass.addMethod(method);
topLevelClass.addInnerClass(innerClass);
}
use of org.mybatis.generator.api.dom.java.FullyQualifiedJavaType in project generator by mybatis.
the class UpdateByExampleSelectiveMethodGenerator method addImplementationElements.
@Override
public void addImplementationElements(TopLevelClass topLevelClass) {
Set<FullyQualifiedJavaType> importedTypes = new TreeSet<FullyQualifiedJavaType>();
Method method = getMethodShell(importedTypes);
method.addBodyLine(//$NON-NLS-1$
"UpdateByExampleParms parms = new UpdateByExampleParms(record, example);");
StringBuilder sb = new StringBuilder();
//$NON-NLS-1$
sb.append("int rows = ");
sb.append(daoTemplate.getUpdateMethod(introspectedTable.getIbatis2SqlMapNamespace(), introspectedTable.getUpdateByExampleSelectiveStatementId(), //$NON-NLS-1$
"parms"));
method.addBodyLine(sb.toString());
//$NON-NLS-1$
method.addBodyLine("return rows;");
if (context.getPlugins().clientUpdateByExampleSelectiveMethodGenerated(method, topLevelClass, introspectedTable)) {
topLevelClass.addImportedTypes(importedTypes);
topLevelClass.addMethod(method);
}
}
use of org.mybatis.generator.api.dom.java.FullyQualifiedJavaType in project generator by mybatis.
the class UpdateByExampleWithBLOBsMethodGenerator method addInterfaceElements.
@Override
public void addInterfaceElements(Interface interfaze) {
if (getExampleMethodVisibility() == JavaVisibility.PUBLIC) {
Set<FullyQualifiedJavaType> importedTypes = new TreeSet<FullyQualifiedJavaType>();
Method method = getMethodShell(importedTypes);
if (context.getPlugins().clientUpdateByExampleWithBLOBsMethodGenerated(method, interfaze, introspectedTable)) {
interfaze.addImportedTypes(importedTypes);
interfaze.addMethod(method);
}
}
}
use of org.mybatis.generator.api.dom.java.FullyQualifiedJavaType in project generator by mybatis.
the class UpdateByExampleWithBLOBsMethodGenerator method addImplementationElements.
@Override
public void addImplementationElements(TopLevelClass topLevelClass) {
Set<FullyQualifiedJavaType> importedTypes = new TreeSet<FullyQualifiedJavaType>();
Method method = getMethodShell(importedTypes);
method.addBodyLine(//$NON-NLS-1$
"UpdateByExampleParms parms = new UpdateByExampleParms(record, example);");
StringBuilder sb = new StringBuilder();
//$NON-NLS-1$
sb.append("int rows = ");
sb.append(daoTemplate.getUpdateMethod(introspectedTable.getIbatis2SqlMapNamespace(), introspectedTable.getUpdateByExampleWithBLOBsStatementId(), //$NON-NLS-1$
"parms"));
method.addBodyLine(sb.toString());
//$NON-NLS-1$
method.addBodyLine("return rows;");
if (context.getPlugins().clientUpdateByExampleWithBLOBsMethodGenerated(method, topLevelClass, introspectedTable)) {
topLevelClass.addImportedTypes(importedTypes);
topLevelClass.addMethod(method);
}
}
use of org.mybatis.generator.api.dom.java.FullyQualifiedJavaType in project generator by mybatis.
the class UpdateByExampleWithBLOBsMethodGenerator 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(getExampleMethodVisibility());
method.setReturnType(FullyQualifiedJavaType.getIntInstance());
method.setName(getDAOMethodNameCalculator().getUpdateByExampleWithBLOBsMethodName(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