use of org.mybatis.generator.api.dom.java.FullyQualifiedJavaType in project generator by mybatis.
the class DAOGenerator method getInterfaceShell.
protected Interface getInterfaceShell() {
Interface answer = new Interface(new FullyQualifiedJavaType(introspectedTable.getDAOInterfaceType()));
answer.setVisibility(JavaVisibility.PUBLIC);
String rootInterface = introspectedTable.getTableConfigurationProperty(PropertyRegistry.ANY_ROOT_INTERFACE);
if (!stringHasValue(rootInterface)) {
rootInterface = context.getJavaClientGeneratorConfiguration().getProperty(PropertyRegistry.ANY_ROOT_INTERFACE);
}
if (stringHasValue(rootInterface)) {
FullyQualifiedJavaType fqjt = new FullyQualifiedJavaType(rootInterface);
answer.addSuperInterface(fqjt);
answer.addImportedType(fqjt);
}
for (FullyQualifiedJavaType fqjt : daoTemplate.getInterfaceImports()) {
answer.addImportedType(fqjt);
}
context.getCommentGenerator().addJavaFileComment(answer);
return answer;
}
use of org.mybatis.generator.api.dom.java.FullyQualifiedJavaType in project generator by mybatis.
the class DatabaseIntrospector method applyColumnOverrides.
/**
* Apply column overrides.
*
* @param tc
* the tc
* @param columns
* the columns
*/
private void applyColumnOverrides(TableConfiguration tc, Map<ActualTableName, List<IntrospectedColumn>> columns) {
for (Map.Entry<ActualTableName, List<IntrospectedColumn>> entry : columns.entrySet()) {
for (IntrospectedColumn introspectedColumn : entry.getValue()) {
ColumnOverride columnOverride = tc.getColumnOverride(introspectedColumn.getActualColumnName());
if (columnOverride != null) {
if (logger.isDebugEnabled()) {
logger.debug(getString(//$NON-NLS-1$
"Tracing.4", introspectedColumn.getActualColumnName(), entry.getKey().toString()));
}
if (stringHasValue(columnOverride.getJavaProperty())) {
introspectedColumn.setJavaProperty(columnOverride.getJavaProperty());
}
if (stringHasValue(columnOverride.getJavaType())) {
introspectedColumn.setFullyQualifiedJavaType(new FullyQualifiedJavaType(columnOverride.getJavaType()));
}
if (stringHasValue(columnOverride.getJdbcType())) {
introspectedColumn.setJdbcTypeName(columnOverride.getJdbcType());
}
if (stringHasValue(columnOverride.getTypeHandler())) {
introspectedColumn.setTypeHandler(columnOverride.getTypeHandler());
}
if (columnOverride.isColumnNameDelimited()) {
introspectedColumn.setColumnNameDelimited(true);
}
introspectedColumn.setGeneratedAlways(columnOverride.isGeneratedAlways());
introspectedColumn.setProperties(columnOverride.getProperties());
}
}
}
}
use of org.mybatis.generator.api.dom.java.FullyQualifiedJavaType 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.FullyQualifiedJavaType in project generator by mybatis.
the class DeleteByExampleMethodGenerator method addImplementationElements.
@Override
public void addImplementationElements(TopLevelClass topLevelClass) {
Set<FullyQualifiedJavaType> importedTypes = new TreeSet<FullyQualifiedJavaType>();
Method method = getMethodShell(importedTypes);
StringBuilder sb = new StringBuilder();
//$NON-NLS-1$
sb.append("int rows = ");
sb.append(daoTemplate.getDeleteMethod(introspectedTable.getIbatis2SqlMapNamespace(), introspectedTable.getDeleteByExampleStatementId(), //$NON-NLS-1$
"example"));
method.addBodyLine(sb.toString());
//$NON-NLS-1$
method.addBodyLine("return rows;");
if (context.getPlugins().clientDeleteByExampleMethodGenerated(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 DeleteByPrimaryKeyMethodGenerator method addInterfaceElements.
@Override
public void addInterfaceElements(Interface interfaze) {
Set<FullyQualifiedJavaType> importedTypes = new TreeSet<FullyQualifiedJavaType>();
Method method = getMethodShell(importedTypes);
if (context.getPlugins().clientDeleteByPrimaryKeyMethodGenerated(method, interfaze, introspectedTable)) {
interfaze.addImportedTypes(importedTypes);
interfaze.addMethod(method);
}
}
Aggregations