Search in sources :

Example 56 with FullyQualifiedJavaType

use of org.mybatis.generator.api.dom.java.FullyQualifiedJavaType in project generator by mybatis.

the class FullyQualifiedJavaTypeTest method testComplexArray.

@Test
public void testComplexArray() {
    FullyQualifiedJavaType fqjt = new FullyQualifiedJavaType("java.util.List<String>[]");
    assertFalse(fqjt.isPrimitive());
    assertTrue(fqjt.isArray());
}
Also used : FullyQualifiedJavaType(org.mybatis.generator.api.dom.java.FullyQualifiedJavaType) Test(org.junit.Test)

Example 57 with FullyQualifiedJavaType

use of org.mybatis.generator.api.dom.java.FullyQualifiedJavaType in project generator by mybatis.

the class FullyQualifiedJavaTypeTest method testSimpleType3.

@Test
public void testSimpleType3() {
    FullyQualifiedJavaType fqjt = //$NON-NLS-1$
    new FullyQualifiedJavaType("int");
    assertFalse(fqjt.isExplicitlyImported());
    //$NON-NLS-1$
    assertEquals("int", fqjt.getShortName());
    //$NON-NLS-1$
    assertEquals("int", fqjt.getFullyQualifiedName());
    //$NON-NLS-1$
    assertEquals("", fqjt.getPackageName());
    assertEquals(0, fqjt.getImportList().size());
}
Also used : FullyQualifiedJavaType(org.mybatis.generator.api.dom.java.FullyQualifiedJavaType) Test(org.junit.Test)

Example 58 with FullyQualifiedJavaType

use of org.mybatis.generator.api.dom.java.FullyQualifiedJavaType in project generator by mybatis.

the class FullyQualifiedJavaTypeTest method testGenericType3.

@Test
public void testGenericType3() {
    //$NON-NLS-1$
    FullyQualifiedJavaType listOfStrings = new FullyQualifiedJavaType("java.util.List");
    //$NON-NLS-1$
    listOfStrings.addTypeArgument(new FullyQualifiedJavaType("java.lang.String"));
    FullyQualifiedJavaType fqjt = //$NON-NLS-1$
    new FullyQualifiedJavaType("java.util.Map");
    //$NON-NLS-1$
    fqjt.addTypeArgument(new FullyQualifiedJavaType("java.lang.String"));
    fqjt.addTypeArgument(listOfStrings);
    assertTrue(fqjt.isExplicitlyImported());
    //$NON-NLS-1$
    assertEquals("Map<String, List<String>>", fqjt.getShortName());
    //$NON-NLS-1$
    assertEquals("java.util.Map<java.lang.String, java.util.List<java.lang.String>>", fqjt.getFullyQualifiedName());
    //$NON-NLS-1$
    assertEquals("java.util", fqjt.getPackageName());
    assertEquals(2, fqjt.getImportList().size());
    //$NON-NLS-1$
    assertEquals("java.util.Map", fqjt.getFullyQualifiedNameWithoutTypeParameters());
}
Also used : FullyQualifiedJavaType(org.mybatis.generator.api.dom.java.FullyQualifiedJavaType) Test(org.junit.Test)

Example 59 with FullyQualifiedJavaType

use of org.mybatis.generator.api.dom.java.FullyQualifiedJavaType in project generator by mybatis.

the class JavaMapperGenerator method getCompilationUnits.

@Override
public List<CompilationUnit> getCompilationUnits() {
    progressCallback.startTask(getString(//$NON-NLS-1$
    "Progress.17", introspectedTable.getFullyQualifiedTable().toString()));
    CommentGenerator commentGenerator = context.getCommentGenerator();
    FullyQualifiedJavaType type = new FullyQualifiedJavaType(introspectedTable.getMyBatis3JavaMapperType());
    Interface interfaze = new Interface(type);
    interfaze.setVisibility(JavaVisibility.PUBLIC);
    commentGenerator.addJavaFileComment(interfaze);
    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);
        interfaze.addSuperInterface(fqjt);
        interfaze.addImportedType(fqjt);
    }
    addCountByExampleMethod(interfaze);
    addDeleteByExampleMethod(interfaze);
    addDeleteByPrimaryKeyMethod(interfaze);
    addInsertMethod(interfaze);
    addInsertSelectiveMethod(interfaze);
    addSelectByExampleWithBLOBsMethod(interfaze);
    addSelectByExampleWithoutBLOBsMethod(interfaze);
    addSelectByPrimaryKeyMethod(interfaze);
    addUpdateByExampleSelectiveMethod(interfaze);
    addUpdateByExampleWithBLOBsMethod(interfaze);
    addUpdateByExampleWithoutBLOBsMethod(interfaze);
    addUpdateByPrimaryKeySelectiveMethod(interfaze);
    addUpdateByPrimaryKeyWithBLOBsMethod(interfaze);
    addUpdateByPrimaryKeyWithoutBLOBsMethod(interfaze);
    List<CompilationUnit> answer = new ArrayList<CompilationUnit>();
    if (context.getPlugins().clientGenerated(interfaze, null, introspectedTable)) {
        answer.add(interfaze);
    }
    List<CompilationUnit> extraCompilationUnits = getExtraCompilationUnits();
    if (extraCompilationUnits != null) {
        answer.addAll(extraCompilationUnits);
    }
    return answer;
}
Also used : CompilationUnit(org.mybatis.generator.api.dom.java.CompilationUnit) CommentGenerator(org.mybatis.generator.api.CommentGenerator) FullyQualifiedJavaType(org.mybatis.generator.api.dom.java.FullyQualifiedJavaType) ArrayList(java.util.ArrayList) Messages.getString(org.mybatis.generator.internal.util.messages.Messages.getString) Interface(org.mybatis.generator.api.dom.java.Interface)

Example 60 with FullyQualifiedJavaType

use of org.mybatis.generator.api.dom.java.FullyQualifiedJavaType in project generator by mybatis.

the class UpdateByPrimaryKeySelectiveMethodGenerator 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(JavaVisibility.PUBLIC);
    method.setReturnType(FullyQualifiedJavaType.getIntInstance());
    method.setName(getDAOMethodNameCalculator().getUpdateByPrimaryKeySelectiveMethodName(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;
}
Also used : FullyQualifiedJavaType(org.mybatis.generator.api.dom.java.FullyQualifiedJavaType) Parameter(org.mybatis.generator.api.dom.java.Parameter) Method(org.mybatis.generator.api.dom.java.Method)

Aggregations

FullyQualifiedJavaType (org.mybatis.generator.api.dom.java.FullyQualifiedJavaType)163 Method (org.mybatis.generator.api.dom.java.Method)97 Parameter (org.mybatis.generator.api.dom.java.Parameter)54 TreeSet (java.util.TreeSet)53 IntrospectedColumn (org.mybatis.generator.api.IntrospectedColumn)32 Test (org.junit.Test)24 ArrayList (java.util.ArrayList)19 Field (org.mybatis.generator.api.dom.java.Field)19 TopLevelClass (org.mybatis.generator.api.dom.java.TopLevelClass)19 Messages.getString (org.mybatis.generator.internal.util.messages.Messages.getString)14 CommentGenerator (org.mybatis.generator.api.CommentGenerator)11 CompilationUnit (org.mybatis.generator.api.dom.java.CompilationUnit)11 Interface (org.mybatis.generator.api.dom.java.Interface)10 FullyQualifiedTable (org.mybatis.generator.api.FullyQualifiedTable)7 GeneratedKey (org.mybatis.generator.config.GeneratedKey)7 Plugin (org.mybatis.generator.api.Plugin)5 Attribute (org.mybatis.generator.api.dom.xml.Attribute)5 TextElement (org.mybatis.generator.api.dom.xml.TextElement)5 XmlElement (org.mybatis.generator.api.dom.xml.XmlElement)5 JavaBeansUtil.getJavaBeansField (org.mybatis.generator.internal.util.JavaBeansUtil.getJavaBeansField)5