当前位置: 首页>>代码示例>>Java>>正文


Java FullyQualifiedJavaType.addTypeArgument方法代码示例

本文整理汇总了Java中org.mybatis.generator.api.dom.java.FullyQualifiedJavaType.addTypeArgument方法的典型用法代码示例。如果您正苦于以下问题:Java FullyQualifiedJavaType.addTypeArgument方法的具体用法?Java FullyQualifiedJavaType.addTypeArgument怎么用?Java FullyQualifiedJavaType.addTypeArgument使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.mybatis.generator.api.dom.java.FullyQualifiedJavaType的用法示例。


在下文中一共展示了FullyQualifiedJavaType.addTypeArgument方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testGenericType3

import org.mybatis.generator.api.dom.java.FullyQualifiedJavaType; //导入方法依赖的package包/类
@Test
public void testGenericType3() {
    FullyQualifiedJavaType listOfStrings = new FullyQualifiedJavaType("java.util.List"); //$NON-NLS-1$
    listOfStrings.addTypeArgument(new FullyQualifiedJavaType("java.lang.String")); //$NON-NLS-1$

    FullyQualifiedJavaType fqjt =
        new FullyQualifiedJavaType("java.util.Map"); //$NON-NLS-1$
    fqjt.addTypeArgument(new FullyQualifiedJavaType("java.lang.String")); //$NON-NLS-1$
    fqjt.addTypeArgument(listOfStrings);

    assertTrue(fqjt.isExplicitlyImported());
    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()); //$NON-NLS-1$
    assertEquals(2, fqjt.getImportList().size());
    assertEquals("java.util.Map", fqjt.getFullyQualifiedNameWithoutTypeParameters()); //$NON-NLS-1$
}
 
开发者ID:bandaotixi,项目名称:generator_mybatis,代码行数:18,代码来源:FullyQualifiedJavaTypeTest.java

示例2: testGenericInterface

import org.mybatis.generator.api.dom.java.FullyQualifiedJavaType; //导入方法依赖的package包/类
@Test
public void testGenericInterface() {
    FullyQualifiedJavaType fqjt = new FullyQualifiedJavaType("org.mybatis.test.TestInterface");
    fqjt.addTypeArgument(new FullyQualifiedJavaType("T"));
    Interface ifc = new Interface(fqjt);
    JavaFormatter jf = new DefaultJavaFormatter();
    GeneratedJavaFile gjf = new GeneratedJavaFile(ifc, "src", jf);
    
    assertEquals("TestInterface.java", gjf.getFileName());
    assertEquals("org.mybatis.test", gjf.getTargetPackage());
}
 
开发者ID:bandaotixi,项目名称:generator_mybatis,代码行数:12,代码来源:GeneratedJavaFileTest.java

示例3: getSetInOrNotInMethod

import org.mybatis.generator.api.dom.java.FullyQualifiedJavaType; //导入方法依赖的package包/类
/**
 * 
 * @param introspectedColumn
 * @param inMethod
 *            if true generates an "in" method, else generates a "not in"
 *            method
 * @return a generated method for the in or not in method
 */
private Method getSetInOrNotInMethod(IntrospectedColumn introspectedColumn,
        boolean inMethod) {
    Method method = new Method();
    method.setVisibility(JavaVisibility.PUBLIC);
    FullyQualifiedJavaType type = FullyQualifiedJavaType
            .getNewListInstance();
    if (generateForJava5) {
        if (introspectedColumn.getFullyQualifiedJavaType().isPrimitive()) {
            type.addTypeArgument(introspectedColumn
                    .getFullyQualifiedJavaType().getPrimitiveTypeWrapper());
        } else {
            type.addTypeArgument(introspectedColumn
                    .getFullyQualifiedJavaType());
        }
    }

    method.addParameter(new Parameter(type, "values")); //$NON-NLS-1$
    StringBuilder sb = new StringBuilder();
    sb.append(introspectedColumn.getJavaProperty());
    sb.setCharAt(0, Character.toUpperCase(sb.charAt(0)));
    sb.insert(0, "and"); //$NON-NLS-1$
    if (inMethod) {
        sb.append("In"); //$NON-NLS-1$
    } else {
        sb.append("NotIn"); //$NON-NLS-1$
    }
    method.setName(sb.toString());
    method.setReturnType(FullyQualifiedJavaType.getCriteriaInstance());
    sb.setLength(0);

    if (introspectedColumn.isJDBCDateColumn()) {
        sb.append("addCriterionForJDBCDate(\""); //$NON-NLS-1$
    } else if (introspectedColumn.isJDBCTimeColumn()) {
        sb.append("addCriterionForJDBCTime(\""); //$NON-NLS-1$
    } else if (stringHasValue(introspectedColumn
            .getTypeHandler())) {
        sb.append("add"); //$NON-NLS-1$
        sb.append(introspectedColumn.getJavaProperty());
        sb.setCharAt(3, Character.toUpperCase(sb.charAt(3)));
        sb.append("Criterion(\""); //$NON-NLS-1$
    } else {
        sb.append("addCriterion(\""); //$NON-NLS-1$
    }

    sb.append(Ibatis2FormattingUtilities
            .getAliasedActualColumnName(introspectedColumn));
    if (inMethod) {
        sb.append(" in"); //$NON-NLS-1$
    } else {
        sb.append(" not in"); //$NON-NLS-1$
    }
    sb.append("\", values, \""); //$NON-NLS-1$
    sb.append(introspectedColumn.getJavaProperty());
    sb.append("\");"); //$NON-NLS-1$
    method.addBodyLine(sb.toString());
    method.addBodyLine("return (Criteria) this;"); //$NON-NLS-1$

    return method;
}
 
开发者ID:bandaotixi,项目名称:generator_mybatis,代码行数:68,代码来源:ExampleGenerator.java

示例4: getSetInOrNotInMethod

import org.mybatis.generator.api.dom.java.FullyQualifiedJavaType; //导入方法依赖的package包/类
/**
 * 
 * @param introspectedColumn
 * @param inMethod
 *            if true generates an "in" method, else generates a "not in"
 *            method
 * @return a generated method for the in or not in method
 */
private Method getSetInOrNotInMethod(IntrospectedColumn introspectedColumn,
        boolean inMethod) {
    Method method = new Method();
    method.setVisibility(JavaVisibility.PUBLIC);
    FullyQualifiedJavaType type = FullyQualifiedJavaType
            .getNewListInstance();
    if (introspectedColumn.getFullyQualifiedJavaType().isPrimitive()) {
        type.addTypeArgument(introspectedColumn.getFullyQualifiedJavaType()
                .getPrimitiveTypeWrapper());
    } else {
        type
                .addTypeArgument(introspectedColumn
                        .getFullyQualifiedJavaType());
    }

    method.addParameter(new Parameter(type, "values")); //$NON-NLS-1$
    StringBuilder sb = new StringBuilder();
    sb.append(introspectedColumn.getJavaProperty());
    sb.setCharAt(0, Character.toUpperCase(sb.charAt(0)));
    sb.insert(0, "and"); //$NON-NLS-1$
    if (inMethod) {
        sb.append("In"); //$NON-NLS-1$
    } else {
        sb.append("NotIn"); //$NON-NLS-1$
    }
    method.setName(sb.toString());
    method.setReturnType(FullyQualifiedJavaType.getCriteriaInstance());
    sb.setLength(0);

    if (introspectedColumn.isJDBCDateColumn()) {
        sb.append("addCriterionForJDBCDate(\""); //$NON-NLS-1$
    } else if (introspectedColumn.isJDBCTimeColumn()) {
        sb.append("addCriterionForJDBCTime(\""); //$NON-NLS-1$
    } else if (stringHasValue(introspectedColumn
            .getTypeHandler())) {
        sb.append("add"); //$NON-NLS-1$
        sb.append(introspectedColumn.getJavaProperty());
        sb.setCharAt(3, Character.toUpperCase(sb.charAt(3)));
        sb.append("Criterion(\""); //$NON-NLS-1$
    } else {
        sb.append("addCriterion(\""); //$NON-NLS-1$
    }

    sb.append(MyBatis3FormattingUtilities
            .getAliasedActualColumnName(introspectedColumn));
    if (inMethod) {
        sb.append(" in"); //$NON-NLS-1$
    } else {
        sb.append(" not in"); //$NON-NLS-1$
    }
    sb.append("\", values, \""); //$NON-NLS-1$
    sb.append(introspectedColumn.getJavaProperty());
    sb.append("\");"); //$NON-NLS-1$
    method.addBodyLine(sb.toString());
    method.addBodyLine("return (Criteria) this;"); //$NON-NLS-1$

    return method;
}
 
开发者ID:bandaotixi,项目名称:generator_mybatis,代码行数:67,代码来源:ExampleGenerator.java


注:本文中的org.mybatis.generator.api.dom.java.FullyQualifiedJavaType.addTypeArgument方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。