private void addUserDefinedMethods(TopLevelClass exampleClass, Interface mapperClass, IntrospectedTable introspectedTable, MyBatisClasses cls) {
        for (Method action : mapperClass.getMethods()) {
            if (!userDefinedMethods.matcher(action.getName()).matches()) continue;
            StringBuilder args = new StringBuilder();
            List<Parameter> params = new ArrayList<Parameter>();
            boolean example = false;
            if (action.getParameters() != null)
                for (Parameter param : action.getParameters()) {
                    String name;
                    if (Objects.equals(param.getType(), exampleClass.getType())) {
                        example = true;
                        name = "this";
                    } else {
                        name = param.getName();
                        params.add(new Parameter(param.getType(), name));
                    }
                    if (args.length() > 0)
                        args.append(", ");
                    args.append(name);
                }
            if (!example) {
                //System.err.println("Invalid user-defined mapper method: "+action.getName());
                continue;
            }

            exampleClass.addMethod(method(
                PUBLIC, INT, action.getName(), _(sqlSession, "sql"), params.toArray(new Parameter[params.size()]), __(
                    "return sql.getMapper(" + cls.names.mapper + ".class)."+action.getName()+"("+args+");"
            )));
            exampleClass.addMethod(method(
                PUBLIC, INT, action.getName(), _(cls.types.mapper, "mapper"), params.toArray(new Parameter[params.size()]), __(
                    "return mapper."+action.getName()+"("+args+");"
            )));
        }
    }
 /** 添加方法 */
 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();
 }
    private void addCriteriaMethods(TopLevelClass topLevelClass, int newMethodsStart) {
        if (!generateCriteriaMethods) return;
        InnerClass criteria = null;
        for (InnerClass c : topLevelClass.getInnerClasses()) {
            if (c.getType().getShortName().equals("Criteria")) criteria = c;
        }
        if (criteria == null) return;
        boolean owner = false;
        for (Field f : criteria.getFields()) if (ExampleMethodsChainPlugin.OWNER.equals(f.getName())) owner = true;
        if (!owner) return;

        for (ListIterator<Method> methods = topLevelClass.getMethods().listIterator(newMethodsStart); methods.hasNext(); ) {
            Method base = methods.next();
            if (base.getVisibility() != PUBLIC || base.isStatic() || base.isConstructor()) continue;
            Method m = method(PUBLIC, base.getReturnType(), base.getName());
            StringBuilder sb = new StringBuilder();
            sb.append("return ").append(ExampleMethodsChainPlugin.OWNER).append(".").append(base.getName()).append("(");
            for (ListIterator<Parameter> params = base.getParameters().listIterator(); params.hasNext(); ) {
                if (params.hasPrevious()) sb.append(", ");
                Parameter p = params.next();
                m.addParameter(new Parameter(p.getType(), p.getName()));
                sb.append(p.getName());
            }
            sb.append(");");
            m.addBodyLine(sb.toString());
            criteria.addMethod(m);
        }
    }
 /** type 的意义 pojo 1 key 2 example 3 pojo+example 4 */
 protected String addParams(IntrospectedTable introspectedTable, Method method, int type1) {
   switch (type1) {
     case 1:
       method.addParameter(new Parameter(pojoType, "record"));
       return "record";
     case 2:
       if (introspectedTable.getRules().generatePrimaryKeyClass()) {
         FullyQualifiedJavaType type =
             new FullyQualifiedJavaType(introspectedTable.getPrimaryKeyType());
         method.addParameter(new Parameter(type, "key"));
       } else {
         for (IntrospectedColumn introspectedColumn : introspectedTable.getPrimaryKeyColumns()) {
           FullyQualifiedJavaType type = introspectedColumn.getFullyQualifiedJavaType();
           method.addParameter(new Parameter(type, introspectedColumn.getJavaProperty()));
         }
       }
       StringBuffer sb = new StringBuffer();
       for (IntrospectedColumn introspectedColumn : introspectedTable.getPrimaryKeyColumns()) {
         sb.append(introspectedColumn.getJavaProperty());
         sb.append(",");
       }
       sb.setLength(sb.length() - 1);
       return sb.toString();
     case 3:
       method.addParameter(new Parameter(pojoCriteriaType, "example"));
       return "example";
     case 4:
       method.addParameter(0, new Parameter(pojoType, "record"));
       method.addParameter(1, new Parameter(pojoCriteriaType, "example"));
       if (method.getName().equals("updateByExampleSelective")
           || method.getName().equals("updateByExample")) {
         return "record, example.getCondition()";
       }
       return "record, example";
     default:
       break;
   }
   return null;
 }