use of org.mybatis.generator.api.dom.java.FullyQualifiedJavaType 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;
}
use of org.mybatis.generator.api.dom.java.FullyQualifiedJavaType in project generator by mybatis.
the class OutputUtilities method calculateImports.
/**
* returns a unique set of "import xxx;" Strings for the set of types.
*
* @param importedTypes
* the imported types
* @return the sets the
*/
public static Set<String> calculateImports(Set<FullyQualifiedJavaType> importedTypes) {
StringBuilder sb = new StringBuilder();
Set<String> importStrings = new TreeSet<String>();
for (FullyQualifiedJavaType fqjt : importedTypes) {
for (String importString : fqjt.getImportList()) {
sb.setLength(0);
//$NON-NLS-1$
sb.append("import ");
sb.append(importString);
sb.append(';');
importStrings.add(sb.toString());
}
}
return importStrings;
}
use of org.mybatis.generator.api.dom.java.FullyQualifiedJavaType in project generator by mybatis.
the class SelectByExampleWithoutBLOBsMethodGenerator method addImplementationElements.
@Override
public void addImplementationElements(TopLevelClass topLevelClass) {
Set<FullyQualifiedJavaType> importedTypes = new TreeSet<FullyQualifiedJavaType>();
Method method = getMethodShell(importedTypes);
if (generateForJava5) {
method.addSuppressTypeWarningsAnnotation();
}
StringBuilder sb = new StringBuilder();
sb.append(method.getReturnType().getShortName());
//$NON-NLS-1$
sb.append(" list = ");
sb.append(daoTemplate.getQueryForListMethod(introspectedTable.getIbatis2SqlMapNamespace(), introspectedTable.getSelectByExampleStatementId(), //$NON-NLS-1$
"example"));
method.addBodyLine(sb.toString());
//$NON-NLS-1$
method.addBodyLine("return list;");
if (context.getPlugins().clientSelectByExampleWithoutBLOBsMethodGenerated(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 SelectByExampleWithoutBLOBsMethodGenerator method getMethodShell.
private Method getMethodShell(Set<FullyQualifiedJavaType> importedTypes) {
FullyQualifiedJavaType type = new FullyQualifiedJavaType(introspectedTable.getExampleType());
importedTypes.add(type);
importedTypes.add(FullyQualifiedJavaType.getNewListInstance());
Method method = new Method();
method.setVisibility(getExampleMethodVisibility());
FullyQualifiedJavaType returnType = FullyQualifiedJavaType.getNewListInstance();
if (generateForJava5) {
FullyQualifiedJavaType fqjt;
if (introspectedTable.getRules().generateBaseRecordClass()) {
fqjt = new FullyQualifiedJavaType(introspectedTable.getBaseRecordType());
} else if (introspectedTable.getRules().generatePrimaryKeyClass()) {
fqjt = new FullyQualifiedJavaType(introspectedTable.getPrimaryKeyType());
} else {
//$NON-NLS-1$
throw new RuntimeException(getString("RuntimeError.12"));
}
importedTypes.add(fqjt);
returnType.addTypeArgument(fqjt);
}
method.setReturnType(returnType);
method.setName(getDAOMethodNameCalculator().getSelectByExampleWithoutBLOBsMethodName(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.FullyQualifiedJavaType in project generator by mybatis.
the class SelectByPrimaryKeyMethodGenerator method getMethodShell.
private Method getMethodShell(Set<FullyQualifiedJavaType> importedTypes) {
Method method = new Method();
method.setVisibility(JavaVisibility.PUBLIC);
FullyQualifiedJavaType returnType = introspectedTable.getRules().calculateAllFieldsClass();
method.setReturnType(returnType);
importedTypes.add(returnType);
method.setName(getDAOMethodNameCalculator().getSelectByPrimaryKeyMethodName(introspectedTable));
if (introspectedTable.getRules().generatePrimaryKeyClass()) {
FullyQualifiedJavaType type = new FullyQualifiedJavaType(introspectedTable.getPrimaryKeyType());
importedTypes.add(type);
//$NON-NLS-1$
method.addParameter(new Parameter(type, "_key"));
} else {
for (IntrospectedColumn introspectedColumn : introspectedTable.getPrimaryKeyColumns()) {
FullyQualifiedJavaType type = introspectedColumn.getFullyQualifiedJavaType();
importedTypes.add(type);
method.addParameter(new Parameter(type, introspectedColumn.getJavaProperty()));
}
}
for (FullyQualifiedJavaType fqjt : daoTemplate.getCheckedExceptions()) {
method.addException(fqjt);
importedTypes.add(fqjt);
}
context.getCommentGenerator().addGeneralMethodComment(method, introspectedTable);
return method;
}
Aggregations