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

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

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

Method.getParameters介绍

[英]Gets the parameters.
[中]获取参数。

代码示例

代码示例来源:origin: abel533/Mapper

/**
 * setter方法注释
 *
 * @param method
 * @param introspectedTable
 * @param introspectedColumn
 */
@Override
public void addSetterComment(Method method, IntrospectedTable introspectedTable, IntrospectedColumn introspectedColumn) {
  StringBuilder sb = new StringBuilder();
  method.addJavaDocLine("/**");
  if (StringUtility.stringHasValue(introspectedColumn.getRemarks())) {
    sb.append(" * 设置");
    sb.append(introspectedColumn.getRemarks());
    method.addJavaDocLine(sb.toString());
    method.addJavaDocLine(" *");
  }
  Parameter parm = method.getParameters().get(0);
  sb.setLength(0);
  sb.append(" * @param ");
  sb.append(parm.getName());
  if (StringUtility.stringHasValue(introspectedColumn.getRemarks())) {
    sb.append(" ");
    sb.append(introspectedColumn.getRemarks());
  }
  method.addJavaDocLine(sb.toString());
  method.addJavaDocLine(" */");
}

代码示例来源:origin: abel533/Mapper

/**
 * setter方法注释
 *
 * @param method
 * @param introspectedTable
 * @param introspectedColumn
 */
@Override
public void addSetterComment(Method method, IntrospectedTable introspectedTable, IntrospectedColumn introspectedColumn) {
  StringBuilder sb = new StringBuilder();
  method.addJavaDocLine("/**");
  if (StringUtility.stringHasValue(introspectedColumn.getRemarks())) {
    sb.append(" * 设置");
    sb.append(introspectedColumn.getRemarks());
    method.addJavaDocLine(sb.toString());
    method.addJavaDocLine(" *");
  }
  Parameter parm = method.getParameters().get(0);
  sb.setLength(0);
  sb.append(" * @param ");
  sb.append(parm.getName());
  if (StringUtility.stringHasValue(introspectedColumn.getRemarks())) {
    sb.append(" ");
    sb.append(introspectedColumn.getRemarks());
  }
  method.addJavaDocLine(sb.toString());
  method.addJavaDocLine(" */");
}

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

bodyline.append(it.getName());
bodyline.append("(");
List<Parameter> params = it.getParameters();
List<String> paramTxt = new ArrayList<>();
for (Parameter p : params) {
bodyline += m.getName();
bodyline += "(";
List<Parameter> params = it.getParameters();
List<String> paramTxt = new ArrayList<>();
for (Parameter p : params) {

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

private void addClientCountByExample(Method method, IntrospectedTable introspectedTable) {
  examples.put(introspectedTable, method.getParameters().get(0).getType());
  addGenericMethod(method, longPrimitive, genericExample);
}

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

private boolean replaceParamType(Method method, IntrospectedTable introspectedTable) {
  if (needPartition(introspectedTable)) {
    for (Parameter parameter : method.getParameters()) {
      try {
        String classType = introspectedTable.getBaseRecordType();
        java.lang.reflect.Field field = parameter.getClass().getDeclaredField("name");
        field.setAccessible(true);
        field.set(parameter, "record");
        field = parameter.getClass().getDeclaredField("type");
        field.setAccessible(true);
        field.set(parameter, new FullyQualifiedJavaType(classType));
      } catch (NoSuchFieldException e) {
        System.err.println("replace parameter type error" + e);
      } catch (IllegalAccessException e) {
        System.err.println("replace parameter type error" + e);
      }
    }
  }
  return true;
}

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

private void addClientDeleteByPrimaryKey(Method method, IntrospectedTable introspectedTable) {
  ids.put(introspectedTable, method.getParameters().get(0).getType());
  addGenericMethod(method, FullyQualifiedJavaType.getIntInstance(), genericId);
}

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

private void addClientInsert(Method method, IntrospectedTable introspectedTable) {
  models.put(introspectedTable, method.getParameters().get(0).getType());
  addGenericMethod(method, FullyQualifiedJavaType.getIntInstance(), genericModel);
}

代码示例来源: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: 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: roncoo/roncoo-mybatis-generator

public void addSetterComment(Method method, IntrospectedTable introspectedTable, IntrospectedColumn introspectedColumn) {
  if (suppressAllComments) {
    return;
  }
  StringBuilder sb = new StringBuilder();
  method.addJavaDocLine("/**"); //$NON-NLS-1$
  method.addJavaDocLine(" * This method was generated by MyBatis Generator."); //$NON-NLS-1$
  sb.append(" * This method sets the value of the database column "); //$NON-NLS-1$
  sb.append(introspectedTable.getFullyQualifiedTable());
  sb.append('.');
  sb.append(introspectedColumn.getActualColumnName());
  method.addJavaDocLine(sb.toString());
  method.addJavaDocLine(" *"); //$NON-NLS-1$
  Parameter parm = method.getParameters().get(0);
  sb.setLength(0);
  sb.append(" * @param "); //$NON-NLS-1$
  sb.append(parm.getName());
  sb.append(" the value for "); //$NON-NLS-1$
  sb.append(introspectedTable.getFullyQualifiedTable());
  sb.append('.');
  sb.append(introspectedColumn.getActualColumnName());
  method.addJavaDocLine(sb.toString());
  addJavadocTag(method, false);
  method.addJavaDocLine(" */"); //$NON-NLS-1$
}

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

private Method generateDecoratedProviderMethod(Method method, TopLevelClass topLevelClass,
                        IntrospectedTable introspectedTable) {
  Method m = new Method(config.methodToGenerateName);
  m.setVisibility(method.getVisibility());
  m.setReturnType(method.getReturnType());
  List<Parameter> params = method.getParameters();
  for (Parameter p : params) {
    m.addParameter(p);
  }
  StringBuilder sb =
      new StringBuilder("String sql = ")
          .append("this.").append(method.getName()).append("(");
  for (Parameter p : params) {
    sb.append(p.getName());
    sb.append(",");
  }
  sb.deleteCharAt(sb.length() - 1);
  sb.append(");");
  m.addBodyLine(sb.toString());
  m.addBodyLine("return \"" + config.sql + "\".replace(\"#{methodToDecorate}\", sql);");
  return m;
}

代码示例来源:origin: vakinge/jeesuite-libs

/**
 * setter方法注释
 *
 * @param method
 * @param introspectedTable
 * @param introspectedColumn
 */
public void addSetterComment(Method method, IntrospectedTable introspectedTable, IntrospectedColumn introspectedColumn) {
  StringBuilder sb = new StringBuilder();
  method.addJavaDocLine("/**");
  if (StringUtility.stringHasValue(introspectedColumn.getRemarks())) {
    sb.append(" * 设置");
    sb.append(introspectedColumn.getRemarks());
    method.addJavaDocLine(sb.toString());
    method.addJavaDocLine(" *");
  }
  Parameter parm = method.getParameters().get(0);
  sb.setLength(0);
  sb.append(" * @param ");
  sb.append(parm.getName());
  if (StringUtility.stringHasValue(introspectedColumn.getRemarks())) {
    sb.append(" ");
    sb.append(introspectedColumn.getRemarks());
  }
  method.addJavaDocLine(sb.toString());
  method.addJavaDocLine(" */");
}

代码示例来源: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: io.github.cgi/mybatis-generator-plugins

private Method generateDecoratedMapperMethod(Method method, IntrospectedTable introspectedTable) {
  Method methodToGenerate = new Method(config.methodToGenerateName);
  methodToGenerate.setVisibility(method.getVisibility());
  methodToGenerate.setReturnType(method.getReturnType());
  context.getCommentGenerator().addGeneralMethodComment(methodToGenerate, introspectedTable);
  List<String> annotations = method.getAnnotations();
  for (String a : annotations) {
    if (a.matches("@.*Provider.*")) {
      methodToGenerate.addAnnotation(a.replace(config.methodToDecorateName, config.methodToGenerateName));
    } else
      methodToGenerate.addAnnotation(a);
  }
  List<Parameter> params = method.getParameters();
  for (Parameter p : params) {
    methodToGenerate.addParameter(p);
  }
  return methodToGenerate;
}

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

private Method generateSelectOneByExample(Method method, IntrospectedTable introspectedTable) {
  Method m = new Method(config.methodToGenerate);
  m.setVisibility(method.getVisibility());
  FullyQualifiedJavaType returnType = introspectedTable.getRules().calculateAllFieldsClass();
  m.setReturnType(returnType);
  List<String> annotations = method.getAnnotations();
  for (String a : annotations) {
    m.addAnnotation(a);
  }
  List<Parameter> params = method.getParameters();
  for (Parameter p : params) {
    m.addParameter(p);
  }
  context.getCommentGenerator().addGeneralMethodComment(m, introspectedTable);
  return m;
}

代码示例来源: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 Method getConstructorClone(CommentGenerator commentGenerator,
    FullyQualifiedJavaType type, IntrospectedTable introspectedTable) {
  configure();
  Method answer = new Method();
  answer.setConstructor(true);
  answer.setName(type.getShortName());
  answer.setVisibility(constructorTemplate.getVisibility());
  for (Parameter parm : constructorTemplate.getParameters()) {
    answer.addParameter(parm);
  }
  for (String bodyLine : constructorTemplate.getBodyLines()) {
    answer.addBodyLine(bodyLine);
  }
  for (FullyQualifiedJavaType fqjt : constructorTemplate.getExceptions()) {
    answer.addException(fqjt);
  }
  commentGenerator.addGeneralMethodComment(answer, introspectedTable);
  return answer;
}

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

public final Method getConstructorClone(CommentGenerator commentGenerator,
    FullyQualifiedJavaType type, IntrospectedTable introspectedTable) {
  configure();
  Method answer = new Method();
  answer.setConstructor(true);
  answer.setName(type.getShortName());
  answer.setVisibility(constructorTemplate.getVisibility());
  for (Parameter parm : constructorTemplate.getParameters()) {
    answer.addParameter(parm);
  }
  for (String bodyLine : constructorTemplate.getBodyLines()) {
    answer.addBodyLine(bodyLine);
  }
  for (FullyQualifiedJavaType fqjt : constructorTemplate.getExceptions()) {
    answer.addException(fqjt);
  }
  commentGenerator.addGeneralMethodComment(answer, introspectedTable);
  return answer;
}

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

public final Method getConstructorClone(CommentGenerator commentGenerator,
    FullyQualifiedJavaType type, IntrospectedTable introspectedTable) {
  configure();
  Method answer = new Method();
  answer.setConstructor(true);
  answer.setName(type.getShortName());
  answer.setVisibility(constructorTemplate.getVisibility());
  for (Parameter parm : constructorTemplate.getParameters()) {
    answer.addParameter(parm);
  }
  for (String bodyLine : constructorTemplate.getBodyLines()) {
    answer.addBodyLine(bodyLine);
  }
  for (FullyQualifiedJavaType fqjt : constructorTemplate.getExceptions()) {
    answer.addException(fqjt);
  }
  commentGenerator.addGeneralMethodComment(answer, introspectedTable);
  return answer;
}

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

public final Method getConstructorClone(CommentGenerator commentGenerator, FullyQualifiedJavaType type,
    IntrospectedTable introspectedTable) {
  configure();
  Method answer = new Method();
  answer.setConstructor(true);
  answer.setName(type.getShortName());
  answer.setVisibility(constructorTemplate.getVisibility());
  for (Parameter parm : constructorTemplate.getParameters()) {
    answer.addParameter(parm);
  }
  for (String bodyLine : constructorTemplate.getBodyLines()) {
    answer.addBodyLine(bodyLine);
  }
  for (FullyQualifiedJavaType fqjt : constructorTemplate.getExceptions()) {
    answer.addException(fqjt);
  }
  commentGenerator.addGeneralMethodComment(answer, introspectedTable);
  return answer;
}

相关文章