org.mybatis.generator.api.dom.java.Method.getName()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(13.6k)|赞(0)|评价(0)|浏览(146)

本文整理了Java中org.mybatis.generator.api.dom.java.Method.getName()方法的一些代码示例,展示了Method.getName()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Method.getName()方法的具体详情如下:
包路径:org.mybatis.generator.api.dom.java.Method
类名称:Method
方法名:getName

Method.getName介绍

暂无

代码示例

代码示例来源:origin: sanluan/PublicCMS

Method m = new Method();
m.setVisibility(JavaVisibility.PUBLIC);
if (it.getName().endsWith("WithRowbounds")) {
  m.setName(it.getName().replace("WithRowbounds", "WithPage"));
  FullyQualifiedJavaType pageHandler = new FullyQualifiedJavaType("com.publiccms.common.handler.PageHandler");
  m.setReturnType(pageHandler);
  StringBuilder bodyline = new StringBuilder();
  bodyline.append("page.setList(mapper.");
  bodyline.append(it.getName());
  bodyline.append("(");
  List<Parameter> params = it.getParameters();
  m.addBodyLine("return page;");
} else {
  m.setName(it.getName());
  m.setReturnType(it.getReturnType());
  topLevelClazz.addImportedType(it.getReturnType());
  String bodyline = "return mapper.";
  bodyline += m.getName();
  bodyline += "(";
  List<Parameter> params = it.getParameters();

代码示例来源:origin: io.github.cgi/mybatis-generator-plugins

boolean shouldApplyGeneration(FullyQualifiedJavaType type, Method method) {
    return !shouldExclude(type) && methodToDecorateName.equals(method.getName());
  }
}

代码示例来源:origin: dcendents/mybatis-generator-plugins

@Override
public boolean modelGetterMethodGenerated(Method method, TopLevelClass topLevelClass,
    IntrospectedColumn introspectedColumn, IntrospectedTable introspectedTable, ModelClassType modelClassType) {
  if (tableMatches(introspectedTable) && gettersToWrap.contains(method.getName())) {
    method.getBodyLines().clear();
    method.addBodyLine(String.format("return this.%s.%s();", objectFieldName, wrappedGetters.get(method.getName())));
  }
  return true;
}

代码示例来源:origin: dcendents/mybatis-generator-plugins

@Override
public boolean modelSetterMethodGenerated(Method method, TopLevelClass topLevelClass,
    IntrospectedColumn introspectedColumn, IntrospectedTable introspectedTable, ModelClassType modelClassType) {
  if (tableMatches(introspectedTable) && settersToWrap.contains(method.getName())) {
    method.getBodyLines().clear();
    method.addBodyLine(String.format("this.%s.%s(%s);", objectFieldName, method.getName(), method
        .getParameters().get(0).getName()));
  }
  return true;
}

代码示例来源:origin: oceanc/mybatis3-generator-plugins

@Override
public boolean clientSelectByPrimaryKeyMethodGenerated(Method method, Interface interfaze, IntrospectedTable introspectedTable) {
  System.out.println("-----------------" + interfaze.getType().getShortName() + " replace parameter type to " + introspectedTable.getBaseRecordType() + " of SelectByPrimaryKey in client class' method " + method.getName());
  return this.replaceParamType(method, introspectedTable);
}

代码示例来源:origin: oceanc/mybatis3-generator-plugins

@Override
public boolean clientDeleteByPrimaryKeyMethodGenerated(Method method, Interface interfaze, IntrospectedTable introspectedTable) {
  System.out.println("-----------------" + interfaze.getType().getShortName() + " replace parameter type to " + introspectedTable.getBaseRecordType() + " of DeleteByPrimaryKey in client class' method " + method.getName());
  return this.replaceParamType(method, introspectedTable);
}

代码示例来源:origin: roncoo/roncoo-mybatis-generator

/**
 * add method
 * 
 */
protected void addMethod(TopLevelClass topLevelClass, String tableName) {
  Method method2 = new Method();
  for (int i = 0; i < methods.size(); i++) {
    Method method = new Method();
    method2 = methods.get(i);
    method = method2;
    method.removeAllBodyLines();
    method.removeAnnotation();
    StringBuilder sb = new StringBuilder();
    sb.append("return this.");
    sb.append(getDaoShort());
    sb.append(method.getName());
    sb.append("(");
    List<Parameter> list = method.getParameters();
    for (int j = 0; j < list.size(); j++) {
      sb.append(list.get(j).getName());
      sb.append(",");
    }
    sb.setLength(sb.length() - 1);
    sb.append(");");
    method.addBodyLine(sb.toString());
    topLevelClass.addMethod(method);
  }
  methods.clear();
}

代码示例来源:origin: oceanc/mybatis3-generator-plugins

@Override
public boolean modelBaseRecordClassGenerated(TopLevelClass topLevelClass, IntrospectedTable introspectedTable) {
  topLevelClass.addAnnotation("@Data");
  topLevelClass.addImportedType(new FullyQualifiedJavaType("lombok.Data"));
  List<Method> methods =  topLevelClass.getMethods();
  List<Method> remove = new ArrayList<Method>();
  for (Method method : methods) {
    if (method.getBodyLines().size() < 2) {
      remove.add(method);
      System.out.println("-----------------" + topLevelClass.getType().getShortName() + "'s method=" + method.getName() + " removed cause lombok annotation.");
    }
  }
  methods.removeAll(remove);
  return true;
}

代码示例来源:origin: dcendents/mybatis-generator-plugins

boolean renameMethod(Method method) {
  String oldMethodName = method.getName();
  Matcher matcher = classMethodPattern.matcher(oldMethodName);
  String newMethodName = matcher.replaceAll(classMethodReplaceString);
  method.setName(newMethodName);
  for (int i = 0; i < method.getParameters().size(); i++) {
    Parameter parameter = method.getParameters().get(i);
    String oldParamName = parameter.getName();
    matcher = parameterPattern.matcher(oldParamName);
    if (matcher.lookingAt()) {
      String newName = matcher.replaceAll(parameterReplaceString);
      Parameter newParam = new Parameter(parameter.getType(), newName, parameter.isVarargs());
      for (String annotation : parameter.getAnnotations()) {
        newParam.addAnnotation(annotation);
      }
      method.getParameters().set(i, newParam);
    }
  }
  return true;
}

代码示例来源:origin: io.github.cgi/mybatis-generator-plugins

/**
 * {@inheritDoc}
 */
@Override
public boolean modelExampleClassGenerated(TopLevelClass topLevelClass,
                     IntrospectedTable introspectedTable) {
  List<InnerClass> innerClasses = topLevelClass.getInnerClasses();
  for (InnerClass innerClass : innerClasses) {
    if ("Criteria".equals(innerClass.getType().getShortName())) {
      addFactoryMethodToCriteria(topLevelClass, innerClass, introspectedTable);
    }
  }
  List<Method> methods = topLevelClass.getMethods();
  for (Method method : methods) {
    if (!"createCriteriaInternal".equals(method.getName()))
      continue;
    method.getBodyLines().set(0, "Criteria criteria = new Criteria(this);");
  }
  return true;
}

代码示例来源:origin: dcendents/mybatis-generator-plugins

Method addMethod(Method method, IntrospectedTable introspectedTable) {
  IntrospectedColumn column = getColumn(introspectedTable);
  Method withLock = new Method(method);
  withLock.setName(method.getName() + METHOD_SUFFIX);
  withLock.getAnnotations().clear();
  for (String line : method.getAnnotations()) {
    if (line.matches("\\s*\".*\"\\s*")) {
      withLock.getAnnotations().add(line + ",");
      String typeHandler = column.getTypeHandler() != null ? String.format(",typeHandler=%s", column.getTypeHandler()) : "";
      withLock.getAnnotations().add(String.format("    \"and %1$s = #{%2$s,jdbcType=%3$s%4$s}\"", lockColumnFunction,
          column.getJavaProperty(), column.getJdbcTypeName(), typeHandler));
    } else {
      withLock.getAnnotations().add(line);
    }
  }
  return withLock;
}

代码示例来源:origin: dcendents/mybatis-generator-plugins

void addGenericMethod(Method method, FullyQualifiedJavaType returnType, FullyQualifiedJavaType... types) {
  method.addAnnotation("@Override");
  if (!methodsAdded.contains(method.getName())) {
    Method genericMethod = new Method(method.getName());
    genericMethod.addJavaDocLine("/**");
    genericMethod.addJavaDocLine(" * This method was generated by MyBatis Generator.");
    genericMethod.addJavaDocLine(" *");
    genericMethod.addJavaDocLine(" * @mbg.generated");
    genericMethod.addJavaDocLine(" */");
    genericMethod.setReturnType(returnType);
    for (int i = 0; i < method.getParameters().size(); i++) {
      Parameter parameter = method.getParameters().get(i);
      FullyQualifiedJavaType paramType = types.length > i ? types[i] : parameter.getType();
      Parameter genericParameter = new Parameter(paramType, parameter.getName());
      genericMethod.addParameter(genericParameter);
    }
    genericInterface.addMethod(genericMethod);
    methodsAdded.add(method.getName());
  }
}

代码示例来源:origin: oceanc/mybatis3-generator-plugins

public static void addProperty(String field, FullyQualifiedJavaType fieldType, TopLevelClass topLevelClass, Context context, String tableName) {
  for (Method method : topLevelClass.getMethods()) {
    if (method.getName().equals("clear")) {
      method.addBodyLine("this." + field + " = null;");
    }
  }
  topLevelClass.addField(makeStringField(context, field, fieldType, tableName));
  topLevelClass.addMethod(makeGetterStringMethod(context, field, fieldType, tableName));
  topLevelClass.addMethod(makeSetterStringMethod(context, field, fieldType, tableName));
  System.out.println("-----------------" + topLevelClass.getType().getShortName() + " add field " + field + " and getter related.");
}

代码示例来源:origin: handosme/mybatis-generator-plus

/**
 * Use the method copy constructor to create a new method, then
 * add the rowBounds parameter.
 * 
 * @param fullyQualifiedTable
 * @param method
 */
private void copyAndAddMethod(Method method, Interface interfaze) {
  Method newMethod = new Method(method);
  newMethod.setName(method.getName() + "WithRowbounds"); //$NON-NLS-1$
  newMethod.addParameter(new Parameter(rowBounds, "rowBounds")); //$NON-NLS-1$
  interfaze.addMethod(newMethod);
  interfaze.addImportedType(rowBounds);
}

代码示例来源:origin: roncoo/roncoo-mybatis-generator

/**
 * Use the method copy constructor to create a new method, then
 * add the rowBounds parameter.
 * 
 * @param fullyQualifiedTable
 * @param method
 */
private void copyAndAddMethod(Method method, Interface interfaze) {
  Method newMethod = new Method(method);
  newMethod.setName(method.getName() + "WithRowbounds"); //$NON-NLS-1$
  newMethod.addParameter(new Parameter(rowBounds, "rowBounds")); //$NON-NLS-1$
  interfaze.addMethod(newMethod);
  interfaze.addImportedType(rowBounds);
}

代码示例来源:origin: org.mybatis.generator/mybatis-generator-core

/**
 * Use the method copy constructor to create a new method, then
 * add the rowBounds parameter.
 * 
 * @param fullyQualifiedTable the table
 * @param method the method
 */
private void copyAndAddMethod(Method method, Interface interfaze) {
  Method newMethod = new Method(method);
  newMethod.setName(method.getName() + "WithRowbounds"); //$NON-NLS-1$
  newMethod.addParameter(new Parameter(rowBounds, "rowBounds")); //$NON-NLS-1$
  interfaze.addMethod(newMethod);
  interfaze.addImportedType(rowBounds);
}

代码示例来源:origin: cxjava/mybatis-generator-core

public final List<Method> getMethodClones(CommentGenerator commentGenerator, IntrospectedTable introspectedTable) {
  configure();
  List<Method> answer = new ArrayList<Method>();
  for (Method oldMethod : methods) {
    Method method = new Method();
    for (String bodyLine : oldMethod.getBodyLines()) {
      method.addBodyLine(bodyLine);
    }
    for (FullyQualifiedJavaType fqjt : oldMethod.getExceptions()) {
      method.addException(fqjt);
    }
    for (Parameter parm : oldMethod.getParameters()) {
      method.addParameter(parm);
    }
    method.setConstructor(oldMethod.isConstructor());
    method.setFinal(oldMethod.isFinal());
    method.setStatic(oldMethod.isStatic());
    method.setName(oldMethod.getName());
    method.setReturnType(oldMethod.getReturnType());
    method.setVisibility(oldMethod.getVisibility());
    commentGenerator.addGeneralMethodComment(method, introspectedTable);
    answer.add(method);
  }
  return answer;
}

代码示例来源:origin: org.mybatis.generator/mybatis-generator-core

public final List<Method> getMethodClones(
    CommentGenerator commentGenerator,
    IntrospectedTable introspectedTable) {
  configure();
  List<Method> answer = new ArrayList<Method>();
  for (Method oldMethod : methods) {
    Method method = new Method();
    for (String bodyLine : oldMethod.getBodyLines()) {
      method.addBodyLine(bodyLine);
    }
    for (FullyQualifiedJavaType fqjt : oldMethod.getExceptions()) {
      method.addException(fqjt);
    }
    for (Parameter parm : oldMethod.getParameters()) {
      method.addParameter(parm);
    }
    method.setConstructor(oldMethod.isConstructor());
    method.setFinal(oldMethod.isFinal());
    method.setStatic(oldMethod.isStatic());
    method.setName(oldMethod.getName());
    method.setReturnType(oldMethod.getReturnType());
    method.setVisibility(oldMethod.getVisibility());
    commentGenerator.addGeneralMethodComment(method, introspectedTable);
    answer.add(method);
  }
  return answer;
}

代码示例来源:origin: roncoo/roncoo-mybatis-generator

public final List<Method> getMethodClones(
    CommentGenerator commentGenerator,
    IntrospectedTable introspectedTable) {
  configure();
  List<Method> answer = new ArrayList<Method>();
  for (Method oldMethod : methods) {
    Method method = new Method();
    for (String bodyLine : oldMethod.getBodyLines()) {
      method.addBodyLine(bodyLine);
    }
    for (FullyQualifiedJavaType fqjt : oldMethod.getExceptions()) {
      method.addException(fqjt);
    }
    for (Parameter parm : oldMethod.getParameters()) {
      method.addParameter(parm);
    }
    method.setConstructor(oldMethod.isConstructor());
    method.setFinal(oldMethod.isFinal());
    method.setStatic(oldMethod.isStatic());
    method.setName(oldMethod.getName());
    method.setReturnType(oldMethod.getReturnType());
    method.setVisibility(oldMethod.getVisibility());
    commentGenerator.addGeneralMethodComment(method, introspectedTable);
    answer.add(method);
  }
  return answer;
}

代码示例来源:origin: handosme/mybatis-generator-plus

public final List<Method> getMethodClones(
    CommentGenerator commentGenerator,
    IntrospectedTable introspectedTable) {
  configure();
  List<Method> answer = new ArrayList<Method>();
  for (Method oldMethod : methods) {
    Method method = new Method();
    for (String bodyLine : oldMethod.getBodyLines()) {
      method.addBodyLine(bodyLine);
    }
    for (FullyQualifiedJavaType fqjt : oldMethod.getExceptions()) {
      method.addException(fqjt);
    }
    for (Parameter parm : oldMethod.getParameters()) {
      method.addParameter(parm);
    }
    method.setConstructor(oldMethod.isConstructor());
    method.setFinal(oldMethod.isFinal());
    method.setStatic(oldMethod.isStatic());
    method.setName(oldMethod.getName());
    method.setReturnType(oldMethod.getReturnType());
    method.setVisibility(oldMethod.getVisibility());
    commentGenerator.addGeneralMethodComment(method, introspectedTable);
    answer.add(method);
  }
  return answer;
}

相关文章