Generate method builder.

@param method
the method
@return the method spec. builder
332743
protected MethodSpec.Builder generateMethodBuilder(SQLiteModelMethod method) {
		MethodSpec.Builder methodBuilder;
		if (method.hasLiveData()) {
			methodBuilder = MethodSpec.methodBuilder(method.getName() + LIVE_DATA_PREFIX).addModifiers(Modifier.PROTECTED);
		} else {
			methodBuilder = MethodSpec.methodBuilder(method.getName()).addAnnotation(Override.class).addModifiers(Modifier.PUBLIC);
		}

		return methodBuilder;
	}
1036442
public static List<AnnotationInstance> createMethodAnnotationList(final MethodInfo method) {
        final List<AnnotationInstance> result = new ArrayList<>();
        for (AnnotationInstance ai : method.annotations()) {
            final AnnotationTarget at = ai.target();
            if (at.kind() == AnnotationTarget.Kind.METHOD) {
                result.add(ai);
            }
        }
        return result;
    }
546124
public static String getMethodDesc(Method method) {
        Assert.notNull(method);
        return getDesc(method.getReturnType(), method.getParameterTypes());
    }
487414
private void buildNewInstanceMethodForBuilder( MethodSpec.Builder newInstanceMethodBuilder ) {
        newInstanceMethodBuilder.addStatement( "return new $T(builderDeserializer.deserializeInline(reader, ctx, params, null, null, null, bufferedProperties).build(), bufferedProperties)",
                parameterizedName( Instance.class, beanInfo.getType() ) );
    }
1290463
public static Parameter[] fromMethod(Method method) {
        Class<?>[] types = method.getParameterTypes();
        Annotation[][] annotations = method.getParameterAnnotations();
        int numParams = types.length;
        Parameter[] params = new Parameter[numParams];

        for (int p = 0; p < numParams; p++) {
            params[p] = new Parameter(types[p], annotations[p]);
        }
        return params;
    }
1002285
protected <S> MethodVault<S> newMethod(Method method)
  {
    if (! Modifier.isAbstract(method.getModifiers())) {
      throw new IllegalStateException(String.valueOf(method));
    }
    else if (method.getName().startsWith("create")) {
      Method target = assetMethod(method);

      if (target != null) {
        return newCreateMethod(target);
      }
      else {
        return newCreateMethodDTO(method);
      }
    }
    else if (method.getName().startsWith("delete")) {
      Method target = assetMethod(method);

      if (target != null) {
        return newDeleteMethod(target);
      }
      else {
        return newDeleteMethodDTO(method);
      }
    }
    else {
      return new MethodVaultNull<>(method.getName() + " " + getClass().getName());
    }
  }
107192
private String createMethodSignature(Method method)
   {
      StringBuilder sb = new StringBuilder();
      sb.append("(");
      for (Class<?> type : method.getParameterTypes())
      {
         sb.append(getTypeString(type));
      }
      sb.append(")");
      Class<?> type = method.getReturnType();
      if (type.getName().equals("void"))
      {
         sb.append("V");
      }
      else
      {
         sb.append(getTypeString(type));
      }
      return sb.toString();
   }
559007
public static void generate(TypeSpec.Builder classBuilder, SQLiteModelMethod method) {
		InsertType insertResultType = detectInsertType(method);

		// if true, field must be associate to ben attributes
		TypeName returnType = method.getReturnClass();

		AssertKripton.failWithInvalidMethodSignException(insertResultType == null, method);

		// generate method code
		MethodSpec.Builder methodBuilder = MethodSpec.methodBuilder(method.getName()).addAnnotation(Override.class)
				.addModifiers(Modifier.PUBLIC);

		ParameterSpec parameterSpec;
		for (Pair<String, TypeName> item : method.getParameters()) {
			parameterSpec = ParameterSpec.builder(item.value1, item.value0).build();
			methodBuilder.addParameter(parameterSpec);
		}
		methodBuilder.returns(returnType);

		// fail if we use jql to INSERT_BEAN with operation of INSERT-FOR-SELECT
		// AssertKripton.failWithInvalidMethodSignException(insertResultType ==
		// InsertType.INSERT_BEAN && method.jql.containsSelectOperation, method,
		// "INSERT-FROM-SELECT SQL can not be used with method sign");

		// generate inner code
		methodBuilder.addComment("Specialized Insert - $L - BEGIN", insertResultType.getClass().getSimpleName());
		insertResultType.generate(classBuilder, methodBuilder, method, returnType);
		methodBuilder.addComment("Specialized Insert - $L - END", insertResultType.getClass().getSimpleName());

		MethodSpec methodSpec = methodBuilder.build();
		classBuilder.addMethod(methodSpec);

		if (method.contentProviderEntryPathEnabled) {
			// we need to generate insert for content provider to
			generateInsertForContentProvider(classBuilder, method, insertResultType);
		}

	}
1164407
function (method, methodName) {
        if (new RegExp("\\.\\$super\\b").exec(method)) {
            return this._createSuperified(method, methodName, _gpfClassMethodExtractSuperMembers(method));
        }
        return method;
    }
1270429
public static String getQualifiedMethodName(Method method) {
		Assert.notNull(method, "Method must not be null");
		return method.getDeclaringClass().getName() + "." + method.getName();
	}
115280
@Override
	public void generate(TypeSpec.Builder classBuilder, boolean mapFields, SQLiteModelMethod method) {
		// SQLiteDaoDefinition daoDefinition = method.getParent();
		String pagedResultName = buildSpecializedPagedResultClass(classBuilder, method);

		Set<JQLProjection> fieldList = JQLChecker.getInstance().extractProjections(method, method.jql.value, method.getEntity());

		{
			MethodSpec.Builder methodBuilder = generateMethodBuilder(method);

			// create PaginatedResult
			createPagedResult(method, pagedResultName, methodBuilder);

			generateCommonPart(method, classBuilder, methodBuilder, fieldList, GenerationType.NO_CONTENT, null, true, false);
			methodBuilder.addStatement("return paginatedResult");

			if (!method.isPagedLiveData()) {
				classBuilder.addMethod(methodBuilder.build());
			}
		}
		
		String selectTotalCountMethodName=method.getName() + "TotalCount";

		// generate paged result method
		{
			MethodSpec.Builder methodBuilder = MethodSpec.methodBuilder(method.getName()).addModifiers(Modifier.PRIVATE);
			generateMethodSignature(method, methodBuilder, TypeUtility.parameterizedTypeName(TypeUtility.className(List.class), TypeUtility.typeName(method.getEntity().getElement())),
					ParameterSpec.builder(TypeUtility.typeName(pagedResultName), "paginatedResult").build());
			
			generateTotalCountUsage(method, methodBuilder, "paginatedResult", selectTotalCountMethodName);

			generateCommonPart(method, classBuilder, methodBuilder, fieldList, GenerationType.NO_METHOD_SIGN, null, false, false,
					JavadocPart.build(JavadocPartType.ADD_PARAMETER, "paginatedResult", "handler of paginated result"), JavadocPart.build(JavadocPartType.RETURN, "", "result list"));

			methodBuilder.addComment("Specialized part II - $L - BEGIN", this.getClass().getSimpleName());
			generateSpecializedPart(method, classBuilder, methodBuilder, fieldList, selectType.isMapFields());
			methodBuilder.addComment("Specialized part II - $L - END", this.getClass().getSimpleName());

			classBuilder.addMethod(methodBuilder.build());
		}

		// generate select count method
		{
			Set<JQLProjection> countfields = new HashSet<>();
			countfields.add(JQLProjection.ProjectionBuilder.create().expression("count(*)").build());

			MethodSpec.Builder methodBuilder = MethodSpec.methodBuilder(selectTotalCountMethodName).addModifiers(Modifier.PRIVATE);
			generateMethodSignature(method, methodBuilder, TypeName.INT, ParameterSpec.builder(TypeUtility.typeName(pagedResultName), "paginatedResult").build());

			generateCommonPart(method, classBuilder, methodBuilder, countfields, GenerationType.NO_METHOD_SIGN, TypeName.INT, false, true,
					JavadocPart.build(JavadocPartType.ADD_PARAMETER, "paginatedResult", "handler of paginated result"), JavadocPart.build(JavadocPartType.RETURN, "", "total row count"));

			methodBuilder.addComment("Specialized part II - $L - BEGIN", this.getClass().getSimpleName());
			generateTotalSpecializedPart(method, methodBuilder);
			methodBuilder.addComment("Specialized part II - $L - END", this.getClass().getSimpleName());

			classBuilder.addMethod(methodBuilder.build());
		}

	}
474713
public String createMethodTypeSignature(ExecutableElement method) {
    if (!hasGenericSignature(method)) {
      return null;
    }
    StringBuilder sb = new StringBuilder();
    genMethodTypeSignature(method, sb);
    return sb.toString();
  }
1210845
public static Map<Integer, List<AnnotationInstance>> createParameterAnnotationMap(final MethodInfo method) {
        final Map<Integer, List<AnnotationInstance>> result = new HashMap<>();
        for (AnnotationInstance ai : method.annotations()) {
            final AnnotationTarget at = ai.target();
            if (at.kind() == AnnotationTarget.Kind.METHOD_PARAMETER) {
                final MethodParameterInfo mp = at.asMethodParameter();
                final int pos = (int) mp.position();
                List<AnnotationInstance> list = result.get(pos);
                if (list == null) {
                    list = new ArrayList<>();
                    result.put(pos, list);
                }
                list.add(ai);
            }
        }
        return result;
    }
130971
public MethodDoc getMatchingMethod(MethodDoc method) {

        MethodDoc[] methods = getMethods();
        for (int i = 0; i < methods.length; i++) {

            if (method.getName().equals(methods[i].getName()) &&
                method.getSignature().equals(methods[i].getSignature())) {

                return methods[i];
            }
        }
        return null;
    }
719122
public static String generateMethodType(MethodType source) {
        StringBuilder builder = new StringBuilder("MethodType.methodType(");
        buildClassArgument(builder, source.returnType());
        if (source.parameterCount() > 0) {
            builder.append(", ");
            buildClassArguments(builder, source.parameterArray());
        }
        builder.append(")");
        return builder.toString();
    }
317403
public void generateJavaDoc(MethodSpec.Builder methodBuilder, final SQLiteModelMethod method, TypeName returnType,
			List<SQLProperty> listUsedProperty, ModelProperty primaryKey) {
		// transform JQL to SQL
		String sqlInsert = JQLChecker.getInstance().replace(method, method.jql, new JQLReplacerListenerImpl(method) {

			@Override
			public String onColumnName(String columnName) {
				Set<SQLProperty> property = currentSchema.getPropertyBySimpleName(columnName);

				SQLProperty tempProperty = property.iterator().next();
				AssertKripton.assertTrueOrUnknownPropertyInJQLException(tempProperty != null, method, columnName);

				return tempProperty.columnName;
			}

			@Override
			public String onBindParameter(String bindParameterName, boolean inStatement) {
				String resolvedParamName = method.findParameterNameByAlias(bindParameterName);

				return SqlAnalyzer.PARAM_PREFIX + resolvedParamName + SqlAnalyzer.PARAM_SUFFIX;
			}

		});

		// generate javadoc and result
		{
			String beanNameParameter = method.findParameterAliasByName(method.getParameters().get(0).value0);

			methodBuilder.addJavadoc("<h2>SQL insert</h2>\n");
			methodBuilder.addJavadoc("<pre>$L</pre>\n\n", sqlInsert);
			methodBuilder.addJavadoc(
					"<p><code>$L.$L</code> is automatically updated because it is the primary key</p>\n",
					beanNameParameter, primaryKey.getName());
			methodBuilder.addJavadoc("\n");

			// list of inserted fields
			methodBuilder.addJavadoc("<p><strong>Inserted columns:</strong></p>\n");
			methodBuilder.addJavadoc("<dl>\n");
			for (SQLProperty property : listUsedProperty) {
				methodBuilder.addJavadoc("\t<dt>$L</dt>", property.columnName);
				methodBuilder.addJavadoc("<dd>is mapped to <strong>$L</strong></dd>\n",
						SqlAnalyzer.PARAM_PREFIX + method.findParameterAliasByName(method.getParameters().get(0).value0)
								+ "." + method.findParameterNameByAlias(property.getName()) + SqlAnalyzer.PARAM_SUFFIX);
			}
			methodBuilder.addJavadoc("</dl>\n\n");

			// update bean have only one parameter: the bean to update
			for (Pair<String, TypeName> param : method.getParameters()) {
				methodBuilder.addJavadoc("@param $L", param.value0);
				methodBuilder.addJavadoc("\n\tis mapped to parameter <strong>$L</strong>\n",
						method.findParameterAliasByName(param.value0));
			}

			InsertRawHelper.generateJavaDocReturnType(methodBuilder, returnType);
		}
	}
1098290
private final void writeMethodTo(CodeBuilder builder) {
    builder.visitCode();
    gen(builder);
    try {
      builder.endMethod();
    } catch (Throwable t) {
      // ASM fails in bizarre ways, attach a trace of the thing we tried to generate to the
      // exception.
      throw new RuntimeException("Failed to generate method:\n" + this, t);
    }
  }