Package org.mybatis.generator.api.dom.java

Examples of org.mybatis.generator.api.dom.java.FullyQualifiedJavaType


  @Override
  public boolean clientGenerated(Interface interfaze, TopLevelClass topLevelClass, IntrospectedTable introspectedTable) {
    // 接口方法
    List<Method> methods = interfaze.getMethods();
    FullyQualifiedJavaType types = new FullyQualifiedJavaType("java.util.Map<java.lang.String, java.lang.Object>");
    Parameter parameter = new Parameter(types, "condition", "@Param(\"condition\")");
    Parameter parameter2 = new Parameter(criteria, "example");
    interfaze.addImportedType(FullyQualifiedJavaType.getNewMapInstance());
    boolean first = true;
    for (int i = 0; i < methods.size(); i++) {
      Method method = methods.get(i);
      if (method.getFormattedContent(0, true).contains("Example")) {
        int size = method.getParameters().size();
        if (first) {
          interfaze.removeImportedType(new FullyQualifiedJavaType(introspectedTable.getExampleType()));
          interfaze.addImportedType(criteria);
        }
        if (size == 1) {
          method.removeParameter(0);
          if (isAllInOne) {
View Full Code Here


          introspectedColumn.setJavaProperty(getValidPropertyName(sb.toString()));
        } else {
          introspectedColumn.setJavaProperty(getCamelCaseString(calculatedColumnName, false));
        }

        FullyQualifiedJavaType fullyQualifiedJavaType = javaTypeResolver.calculateJavaType(introspectedColumn);

        if (fullyQualifiedJavaType != null) {
          introspectedColumn.setFullyQualifiedJavaType(fullyQualifiedJavaType);
          introspectedColumn.setJdbcTypeName(javaTypeResolver.calculateJdbcTypeName(introspectedColumn));
        } else {
View Full Code Here

          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());
View Full Code Here

      answer = introspectedTable.getBaseRecordType();
    } else {
      answer = introspectedTable.getPrimaryKeyType();
    }

    return new FullyQualifiedJavaType(answer);
  }
View Full Code Here

    super();
    properties = new Properties();
    typeMap = new HashMap<Integer, JdbcTypeInformation>();

    typeMap.put(Types.ARRAY, new JdbcTypeInformation("ARRAY", //$NON-NLS-1$
        new FullyQualifiedJavaType(Object.class.getName())));
    typeMap.put(Types.BIGINT, new JdbcTypeInformation("BIGINT", //$NON-NLS-1$
        new FullyQualifiedJavaType(Long.class.getName())));
    typeMap.put(Types.BINARY, new JdbcTypeInformation("BINARY", //$NON-NLS-1$
        new FullyQualifiedJavaType("byte[]"))); //$NON-NLS-1$
    typeMap.put(Types.BIT, new JdbcTypeInformation("BIT", //$NON-NLS-1$
        new FullyQualifiedJavaType(Boolean.class.getName())));
    typeMap.put(Types.BLOB, new JdbcTypeInformation("BLOB", //$NON-NLS-1$
        new FullyQualifiedJavaType("byte[]"))); //$NON-NLS-1$
    typeMap.put(Types.BOOLEAN, new JdbcTypeInformation("BOOLEAN", //$NON-NLS-1$
        new FullyQualifiedJavaType(Boolean.class.getName())));
    typeMap.put(Types.CHAR, new JdbcTypeInformation("CHAR", //$NON-NLS-1$
        new FullyQualifiedJavaType(String.class.getName())));
    typeMap.put(Types.CLOB, new JdbcTypeInformation("CLOB", //$NON-NLS-1$
        new FullyQualifiedJavaType(String.class.getName())));
    typeMap.put(Types.DATALINK, new JdbcTypeInformation("DATALINK", //$NON-NLS-1$
        new FullyQualifiedJavaType(Object.class.getName())));
    typeMap.put(Types.DATE, new JdbcTypeInformation("DATE", //$NON-NLS-1$
        new FullyQualifiedJavaType(Date.class.getName())));
    typeMap.put(Types.DISTINCT, new JdbcTypeInformation("DISTINCT", //$NON-NLS-1$
        new FullyQualifiedJavaType(Object.class.getName())));
    typeMap.put(Types.DOUBLE, new JdbcTypeInformation("DOUBLE", //$NON-NLS-1$
        new FullyQualifiedJavaType(Double.class.getName())));
    typeMap.put(Types.FLOAT, new JdbcTypeInformation("FLOAT", //$NON-NLS-1$
        new FullyQualifiedJavaType(Double.class.getName())));
    typeMap.put(Types.INTEGER, new JdbcTypeInformation("INTEGER", //$NON-NLS-1$
        new FullyQualifiedJavaType(Integer.class.getName())));
    typeMap.put(Types.JAVA_OBJECT, new JdbcTypeInformation("JAVA_OBJECT", //$NON-NLS-1$
        new FullyQualifiedJavaType(Object.class.getName())));
    typeMap.put(Types.LONGVARBINARY, new JdbcTypeInformation("LONGVARBINARY", //$NON-NLS-1$
        new FullyQualifiedJavaType("byte[]"))); //$NON-NLS-1$
    typeMap.put(Types.LONGVARCHAR, new JdbcTypeInformation("LONGVARCHAR", //$NON-NLS-1$
        new FullyQualifiedJavaType(String.class.getName())));
    typeMap.put(NCHAR, new JdbcTypeInformation("NCHAR", //$NON-NLS-1$
        new FullyQualifiedJavaType(String.class.getName())));
    typeMap.put(NCLOB, new JdbcTypeInformation("NCLOB", //$NON-NLS-1$
        new FullyQualifiedJavaType(String.class.getName())));
    typeMap.put(NVARCHAR, new JdbcTypeInformation("NVARCHAR", //$NON-NLS-1$
        new FullyQualifiedJavaType(String.class.getName())));
    typeMap.put(Types.NULL, new JdbcTypeInformation("NULL", //$NON-NLS-1$
        new FullyQualifiedJavaType(Object.class.getName())));
    typeMap.put(Types.OTHER, new JdbcTypeInformation("OTHER", //$NON-NLS-1$
        new FullyQualifiedJavaType(Object.class.getName())));
    typeMap.put(Types.REAL, new JdbcTypeInformation("REAL", //$NON-NLS-1$
        new FullyQualifiedJavaType(Float.class.getName())));
    typeMap.put(Types.REF, new JdbcTypeInformation("REF", //$NON-NLS-1$
        new FullyQualifiedJavaType(Object.class.getName())));
    typeMap.put(Types.SMALLINT, new JdbcTypeInformation("SMALLINT", //$NON-NLS-1$
        new FullyQualifiedJavaType(Short.class.getName())));
    typeMap.put(Types.STRUCT, new JdbcTypeInformation("STRUCT", //$NON-NLS-1$
        new FullyQualifiedJavaType(Object.class.getName())));
    typeMap.put(Types.TIME, new JdbcTypeInformation("TIME", //$NON-NLS-1$
        new FullyQualifiedJavaType(Date.class.getName())));
    typeMap.put(Types.TIMESTAMP, new JdbcTypeInformation("TIMESTAMP", //$NON-NLS-1$
        new FullyQualifiedJavaType(Date.class.getName())));
    typeMap.put(Types.TINYINT, new JdbcTypeInformation("TINYINT", //$NON-NLS-1$
        new FullyQualifiedJavaType(Byte.class.getName())));
    typeMap.put(Types.VARBINARY, new JdbcTypeInformation("VARBINARY", //$NON-NLS-1$
        new FullyQualifiedJavaType("byte[]"))); //$NON-NLS-1$
    typeMap.put(Types.VARCHAR, new JdbcTypeInformation("VARCHAR", //$NON-NLS-1$
        new FullyQualifiedJavaType(String.class.getName())));

  }
View Full Code Here

    forceBigDecimals = StringUtility.isTrue(properties
        .getProperty(PropertyRegistry.TYPE_RESOLVER_FORCE_BIG_DECIMALS));
  }

  public FullyQualifiedJavaType calculateJavaType(IntrospectedColumn introspectedColumn) {
    FullyQualifiedJavaType answer;
    JdbcTypeInformation jdbcTypeInformation = typeMap.get(introspectedColumn.getJdbcType());

    if (jdbcTypeInformation == null) {
      switch (introspectedColumn.getJdbcType()) {
      case Types.DECIMAL:
      case Types.NUMERIC:
        if (introspectedColumn.getScale() > 0 || introspectedColumn.getLength() > 18 || forceBigDecimals) {
          answer = new FullyQualifiedJavaType(BigDecimal.class.getName());
        } else if (introspectedColumn.getLength() > 9) {
          answer = new FullyQualifiedJavaType(Long.class.getName());
        } else if (introspectedColumn.getLength() > 4) {
          answer = new FullyQualifiedJavaType(Integer.class.getName());
        } else {
          answer = new FullyQualifiedJavaType(Short.class.getName());
        }
        break;

      default:
        answer = null;
View Full Code Here

    boolean hasTemp = false;
    Iterator<IntrospectedColumn> iter = introspectedColumns.iterator();
    while (iter.hasNext()) {
      IntrospectedColumn introspectedColumn = iter.next();

      FullyQualifiedJavaType fqjt = introspectedColumn.getFullyQualifiedJavaType();

      String getterMethod = getGetterMethodName(introspectedColumn.getJavaProperty(), fqjt);

      sb.setLength(0);
      if (fqjt.isPrimitive()) {
        if ("boolean".equals(fqjt.getFullyQualifiedName())) { //$NON-NLS-1$
          sb.append("result = prime * result + ("); //$NON-NLS-1$
          sb.append(getterMethod);
          sb.append("() ? 1231 : 1237);"); //$NON-NLS-1$
          method.addBodyLine(sb.toString());
        } else if ("byte".equals(fqjt.getFullyQualifiedName())) { //$NON-NLS-1$
          sb.append("result = prime * result + "); //$NON-NLS-1$
          sb.append(getterMethod);
          sb.append("();"); //$NON-NLS-1$
          method.addBodyLine(sb.toString());
        } else if ("char".equals(fqjt.getFullyQualifiedName())) { //$NON-NLS-1$
          sb.append("result = prime * result + "); //$NON-NLS-1$
          sb.append(getterMethod);
          sb.append("();"); //$NON-NLS-1$
          method.addBodyLine(sb.toString());
        } else if ("double".equals(fqjt.getFullyQualifiedName())) { //$NON-NLS-1$
          if (!hasTemp) {
            method.addBodyLine("long temp;"); //$NON-NLS-1$
            hasTemp = true;
          }
          sb.append("temp = Double.doubleToLongBits("); //$NON-NLS-1$
          sb.append(getterMethod);
          sb.append("());"); //$NON-NLS-1$
          method.addBodyLine(sb.toString());
          method.addBodyLine("result = prime * result + (int) (temp ^ (temp >>> 32));"); //$NON-NLS-1$
        } else if ("float".equals(fqjt.getFullyQualifiedName())) { //$NON-NLS-1$
          sb.append("result = prime * result + Float.floatToIntBits("); //$NON-NLS-1$
          sb.append(getterMethod);
          sb.append("());"); //$NON-NLS-1$
          method.addBodyLine(sb.toString());
        } else if ("int".equals(fqjt.getFullyQualifiedName())) { //$NON-NLS-1$
          sb.append("result = prime * result + "); //$NON-NLS-1$
          sb.append(getterMethod);
          sb.append("();"); //$NON-NLS-1$
          method.addBodyLine(sb.toString());
        } else if ("long".equals(fqjt.getFullyQualifiedName())) { //$NON-NLS-1$
          sb.append("result = prime * result + (int) ("); //$NON-NLS-1$
          sb.append(getterMethod);
          sb.append("() ^ ("); //$NON-NLS-1$
          sb.append(getterMethod);
          sb.append("() >>> 32));"); //$NON-NLS-1$
          method.addBodyLine(sb.toString());
        } else if ("short".equals(fqjt.getFullyQualifiedName())) { //$NON-NLS-1$
          sb.append("result = prime * result + "); //$NON-NLS-1$
          sb.append(getterMethod);
          sb.append("();"); //$NON-NLS-1$
          method.addBodyLine(sb.toString());
        } else {
View Full Code Here

*/
public class FullyQualifiedJavaTypeTest {

    @Test
    public void testJavaType() {
        FullyQualifiedJavaType fqjt =
            new FullyQualifiedJavaType("java.lang.String"); //$NON-NLS-1$
        assertFalse(fqjt.isExplicitlyImported());
        assertEquals("String", fqjt.getShortName()); //$NON-NLS-1$
        assertEquals("java.lang.String", fqjt.getFullyQualifiedName()); //$NON-NLS-1$
        assertEquals("java.lang", fqjt.getPackageName()); //$NON-NLS-1$
        assertEquals(0, fqjt.getImportList().size());
    }
View Full Code Here

        assertEquals(0, fqjt.getImportList().size());
    }

    @Test
    public void testSimpleType() {
        FullyQualifiedJavaType fqjt =
            new FullyQualifiedJavaType("com.foo.Bar"); //$NON-NLS-1$
        assertTrue(fqjt.isExplicitlyImported());
        assertEquals("Bar", fqjt.getShortName()); //$NON-NLS-1$
        assertEquals("com.foo.Bar", fqjt.getFullyQualifiedName()); //$NON-NLS-1$
        assertEquals("com.foo", fqjt.getPackageName()); //$NON-NLS-1$
        assertEquals(1, fqjt.getImportList().size());
        assertEquals("com.foo.Bar", fqjt.getImportList().get(0));
    }
View Full Code Here

        assertEquals("com.foo.Bar", fqjt.getImportList().get(0));
    }

    @Test
    public void testSimpleType2() {
        FullyQualifiedJavaType fqjt =
            new FullyQualifiedJavaType("com.foo.bar"); //$NON-NLS-1$
        assertTrue(fqjt.isExplicitlyImported());
        assertEquals("bar", fqjt.getShortName()); //$NON-NLS-1$
        assertEquals("com.foo.bar", fqjt.getFullyQualifiedName()); //$NON-NLS-1$
        assertEquals("com.foo", fqjt.getPackageName()); //$NON-NLS-1$
        assertEquals(1, fqjt.getImportList().size());
        assertEquals("com.foo.bar", fqjt.getImportList().get(0));
    }
View Full Code Here

TOP

Related Classes of org.mybatis.generator.api.dom.java.FullyQualifiedJavaType

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.