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

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


    // add field, getter, setter for orderby clause
    // @Resource private UserMapper userMapper;
    type = new FullyQualifiedJavaType("javax.annotation.Resource");
    importedTypes.add(type);

    Field field = new Field();
    field.setVisibility(JavaVisibility.PRIVATE);
    String mapper = introspectedTable.getMyBatis3JavaMapperType();
    type = new FullyQualifiedJavaType(mapper);
    field.setType(type);
    idx = mapper.lastIndexOf(".");
    if (idx != -1)
    {
      mapper = mapper.substring(idx + 1);
    }
    mapper = mapper.substring(0, 1).toLowerCase() + mapper.substring(1);
    field.setName(mapper);
    field.addAnnotation("@Resource");
    topLevelClass.addField(field);
    importedTypes.add(type);
    topLevelClass.addImportedTypes(importedTypes);

    // add Method....
View Full Code Here


  }

  private void addField(String fieldName, FullyQualifiedJavaType fieldType,
      TopLevelClass topLevelClass, String javaDocLine)
  {
    Field tmpField = new Field(fieldName, fieldType);
    tmpField.setVisibility(JavaVisibility.PRIVATE);
    tmpField.addJavaDocLine(javaDocLine);
    topLevelClass.addField(tmpField);

    Method setMethod = new Method();
    setMethod.setName("set" + fieldName.toUpperCase().substring(0, 1)
        + fieldName.substring(1));
View Full Code Here

    // add field, getter, setter for orderby clause
    // @Resource
    // private IUserService userService;
    type = new FullyQualifiedJavaType("javax.annotation.Resource");
    importedTypes.add(type);
    Field field = new Field();
    field.setVisibility(JavaVisibility.PRIVATE);
    type = new FullyQualifiedJavaType(serviceInterfaceFullName);
    importedTypes.add(type);
    field.setType(type);
    field.setName(serviceObjName); //$NON-NLS-1$
    field.addAnnotation("@Resource");
    topLevelClass.addField(field);

    // private Pagination page;
    field = new Field();
    field.setVisibility(JavaVisibility.PRIVATE);
    type = new FullyQualifiedJavaType("com.eatle.utils.Pagination");
    importedTypes.add(type);
    field.setType(type);
    field.setName("page");
    topLevelClass.addField(field);

    field = new Field();
    field.setVisibility(JavaVisibility.PRIVATE);
    type = new FullyQualifiedJavaType(recordFullType);
    field.setType(type);
    field.setName(recordLowerFullType);
    topLevelClass.addField(field);
    topLevelClass.addImportedTypes(importedTypes);
    // setter getter
    addSetPageMethod(topLevelClass, introspectedTable);
    addGetPageMethod(topLevelClass, introspectedTable);
View Full Code Here

  }

  private void addField(String fieldName, FullyQualifiedJavaType fieldType,
      TopLevelClass topLevelClass, String javaDocLine)
  {
    Field tmpField = new Field(fieldName, fieldType);
    tmpField.setVisibility(JavaVisibility.PRIVATE);
    tmpField.addJavaDocLine(javaDocLine);
    topLevelClass.addField(tmpField);

    Method setMethod = new Method();
    setMethod.setName("set" + fieldName.toUpperCase().substring(0, 1)
        + fieldName.substring(1));
View Full Code Here

    method.addParameter(new Parameter(new FullyQualifiedJavaType(introspectedTable.getExampleType()), "example")); //$NON-NLS-1$
    method.addBodyLine("super(example);"); //$NON-NLS-1$
    method.addBodyLine("this.record = record;"); //$NON-NLS-1$
    innerClass.addMethod(method);

    Field field = new Field();
    field.setVisibility(JavaVisibility.PRIVATE);
    field.setType(FullyQualifiedJavaType.getObjectInstance());
    field.setName("record"); //$NON-NLS-1$
    innerClass.addField(field);

    method = new Method();
    method.setVisibility(JavaVisibility.PUBLIC);
    method.setReturnType(FullyQualifiedJavaType.getObjectInstance());
View Full Code Here

  /**
   * 导入logger
   */
  private void addLogger(TopLevelClass topLevelClass) {
    Field field = new Field();
    field.setFinal(true);
    field.setInitializationString("LoggerFactory.getLogger(" + topLevelClass.getType().getShortName() + ".class)"); // 设置值
    field.setName("logger"); // 设置变量名
    field.setStatic(true);
    field.setType(new FullyQualifiedJavaType("Logger")); // 类型
    field.setVisibility(JavaVisibility.PRIVATE);
    topLevelClass.addField(field);
  }
View Full Code Here

   *
   * @param topLevelClass
   */
  protected void addField(TopLevelClass topLevelClass, String tableName) {
    // 添加 dao
    Field field = new Field();
    field.setName(toLowerCase(daoType.getShortName())); // 设置变量名
    topLevelClass.addImportedType(daoType);
    field.setType(daoType); // 类型
    field.setVisibility(JavaVisibility.PRIVATE);
    if (enableAnnotation) {
      field.addAnnotation("@Autowired");
    }
    topLevelClass.addField(field);
  }
View Full Code Here

   *
   * @param topLevelClass
   */
  protected void addField(TopLevelClass topLevelClass) {
    // 添加 success
    Field field = new Field();
    field.setName("success"); // 设置变量名
    field.setType(FullyQualifiedJavaType.getBooleanPrimitiveInstance()); // 类型
    field.setVisibility(JavaVisibility.PRIVATE);
    addComment(field, "执行结果");
    topLevelClass.addField(field);
    // 设置结果
    field = new Field();
    field.setName("message"); // 设置变量名
    field.setType(FullyQualifiedJavaType.getStringInstance()); // 类型
    field.setVisibility(JavaVisibility.PRIVATE);
    addComment(field, "消息结果");
    topLevelClass.addField(field);
  }
View Full Code Here

  /**
   * 导入logger
   */
  private void addLogger(TopLevelClass topLevelClass) {
    Field field = new Field();
    field.setFinal(true);
    field.setInitializationString("LoggerFactory.getLogger(" + topLevelClass.getType().getShortName() + ".class)"); // 设置值
    field.setName("logger"); // 设置变量名
    field.setStatic(true);
    field.setType(new FullyQualifiedJavaType("Logger")); // 类型
    field.setVisibility(JavaVisibility.PRIVATE);
    topLevelClass.addField(field);
  }
View Full Code Here

  protected void makeSerializable(TopLevelClass topLevelClass, IntrospectedTable introspectedTable) {
    topLevelClass.addImportedType(serializable);
    topLevelClass.addSuperInterface(serializable);

    Field field = new Field();
    field.setFinal(true);
    Long temp=Long.valueOf(RandomStringUtils.randomNumeric(18));
    field.setInitializationString(temp+"L"); //$NON-NLS-1$
    field.setName("serialVersionUID"); //$NON-NLS-1$
    field.setStatic(true);
    field.setType(new FullyQualifiedJavaType("long")); //$NON-NLS-1$
    field.setVisibility(JavaVisibility.PRIVATE);
    context.getCommentGenerator().addFieldComment(field, introspectedTable);

    topLevelClass.addField(0, field);
  }
View Full Code Here

TOP

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

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.