Loads the method to generate.
@return the method to generate
350893
public Method loadMethod(){
		methodToGenerate = new Method();
		
		// the method will be created in the mapper
		membership = Membership.MAPPER;
		// class to which it belongs
		methodToGenerate.setClazz(configClass);
		
		Class<?> destinationClass = destinationField.getType();
		Class<?> sourceClass = sourceField.getType();
		
		// Return Type definition
		methodToGenerate.setReturnType(destinationClass);
		
		// Parameters type definition
		switch (methodDefined.getParameterNumber()) {
			case ZERO:methodToGenerate.setParameters(new Class<?>[]{});				    			break;
			case ONE: methodToGenerate.setParameters(new Class<?>[]{sourceClass});				    break;
			case TWO: methodToGenerate.setParameters(new Class<?>[]{destinationClass,sourceClass}); break;
		}
		
		// setting of conversion method name
		methodToGenerate.setOriginalName(methodDefined.getName());
		
		// Method name definition
		switch (methodDefined.getType()) {
			case STATIC:  methodToGenerate.setName(definedName());break;
			case DYNAMIC: methodToGenerate.setName(dynamicName());break;
		}
		
		// adds the generated name in the defined method
		methodDefined.setName(methodToGenerate.getName());
		
		int count = 1;
		String body = "{try{";
		// Parameters type definition
		switch (methodDefined.getParameterNumber()) {
			case TWO: String dType = placeholders.get(destinationTypePattern);
				  	  String dName = placeholders.get(destinationPattern);
				  	  body += dType+" "+dName+" = ("+dType+") $"+count+++";"+newLine;
			case ONE: String sType = placeholders.get(sourceTypePattern);
		  	  		  String sName = placeholders.get(sourcePattern);
		  	  		  body += sType+" "+sName+" = ("+sType+") $"+count+";"+newLine;
			default: break;
		}
		
		// Method body definition
		body += methodDefined.getContent();
		for (Entry<String, String> pair : placeholders.entrySet())
			// only if the placeholder is used
			if(!isNull(pair.getValue()))
				body = body.replaceAll(pair.getKey(),  Matcher.quoteReplacement(pair.getValue()));
		return methodToGenerate.setBody(body+"}catch(java.lang.Exception e){"+error()+"}return "+defaultPrimitiveValue(destinationClass)+";}");
	}
413182
public MethodInfo[] getMethods() {
        int size = mMethods.size();
        List<MethodInfo> methodsOnly = new ArrayList<MethodInfo>(size);

        for (int i=0; i<size; i++) {
            MethodInfo method = mMethods.get(i);
            String name = method.getName();
            if (!"<init>".equals(name) && !"<clinit>".equals(name)) {
                methodsOnly.add(method);
            }
        }

        MethodInfo[] methodsArray = new MethodInfo[methodsOnly.size()];
        return methodsOnly.toArray(methodsArray);
    }
947706
protected GeneratorConfig createDefaultGeneratorConfig() {
		final GeneratorConfig config = new GeneratorConfig();
		if (this.defaultVersion == null) {
			this.defaultVersion = JavaVersion.fromQualifier(System.getProperty("java.specification.version")); //$NON-NLS-1$
			if (this.defaultVersion != null) {
				config.setJavaSourceVersion(this.defaultVersion);
			}
		} else {
			config.setJavaSourceVersion(this.defaultVersion);
		}
		return config;
	}
921093
public DataSourceBuilder<?> initializeDataSourceBuilder() {
		return DataSourceBuilder.create(getClassLoader()).type(getType())
				.driverClassName(determineDriverClassName()).url(determineUrl())
				.username(determineUsername()).password(determinePassword());
	}
23400
public JsonElement generate() {
        if(schema.getType().get(0).equals(TYPE_OBJECT)) {
            return new ObjectGenerator(schema, configuration).generate();
        }
        if(schema.getType().get(0).equals(TYPE_ARRAY)) {
            return new ArrayGenerator(schema, configuration).generate();
        }



        throw new UnsupportedOperationException("Use Main generator only for full valid JSON object or array.");
    }
914046
public java.lang.String getRequestMethod() {
    java.lang.Object ref = requestMethod_;
    if (ref instanceof java.lang.String) {
      return (java.lang.String) ref;
    } else {
      com.google.protobuf.ByteString bs = 
          (com.google.protobuf.ByteString) ref;
      java.lang.String s = bs.toStringUtf8();
      requestMethod_ = s;
      return s;
    }
  }
341730
def generate
      generators.each do |generator|
        start = Time.now
        generator.generate(self)
        Bunto.logger.debug "Generating:",
          "#{generator.class} finished in #{Time.now - start} seconds."
      end
    end
921083
protected void maybeLoadMethods ()
    {
        if (_methodMap == null) {
            _methodMap = new HashMap<String,List<Member>>();
            Method[] methods = _clazz.getMethods();

            for (int i = 0; i < methods.length; ++i) {
                Method m = methods[i];
                String methodName = m.getName();
                Class<?>[] paramTypes = m.getParameterTypes();

                List<Member> list = _methodMap.get(methodName);
                if (list == null) {
                    list = new ArrayList<Member>();
                    _methodMap.put(methodName, list);
                }

                if (!ClassUtil.classIsAccessible(_clazz)) {
                    m = ClassUtil.getAccessibleMethodFrom(_clazz, methodName, paramTypes );
                }

                if (m != null) {
                    list.add(m);
                    _paramMap.put(m, paramTypes);
                }
            }
        }
    }
865782
private static Method getMethodDrawString() {
        try {
            Class<?> clazz = Class.forName(SWING_UTILITIES2_NAME);
            return clazz.getMethod(
                    "drawString",
                    new Class[]{JComponent.class, Graphics.class, String.class, Integer.TYPE, Integer.TYPE}
            );
        } catch (ClassNotFoundException e) {
            // returns null
        } catch (SecurityException e) {
            // returns null
        } catch (NoSuchMethodException e) {
            // returns null
        }
        return null;
    }
770675
public Method loadClassAndGetMethod() throws IllegalArgumentException {
        final MethodParameterInfo[] allParameterInfo = getParameterInfo();
        final List<Class<?>> parameterClasses = new ArrayList<>(allParameterInfo.length);
        for (final MethodParameterInfo mpi : allParameterInfo) {
            final TypeSignature parameterType = mpi.getTypeSignatureOrTypeDescriptor();
            parameterClasses.add(parameterType.loadClass());
        }
        final Class<?>[] parameterClassesArr = parameterClasses.toArray(new Class<?>[0]);
        try {
            return loadClass().getMethod(getName(), parameterClassesArr);
        } catch (final NoSuchMethodException e1) {
            try {
                return loadClass().getDeclaredMethod(getName(), parameterClassesArr);
            } catch (final NoSuchMethodException es2) {
                throw new IllegalArgumentException("No such method: " + getClassName() + "." + getName());
            }
        }
    }
301853
public JavaFile generate() {
    MethodSpec privateConstructor = MethodSpec.constructorBuilder()
        .addModifiers(Modifier.PRIVATE)
        .build();

    TypeSpec.Builder casesClassBuilder = TypeSpec.classBuilder(className)
        .addModifiers(Modifier.PUBLIC, Modifier.FINAL)
        .addMethod(privateConstructor)
        .addMethods(methods);

    for (String javadoc : javadocs) {
      casesClassBuilder.addJavadoc(javadoc);
    }

    TypeSpec casesClass = casesClassBuilder.build();

    JavaFile.Builder javaFileBuilder = JavaFile.builder(packageName, casesClass);

    if (fileComment != null) {
      javaFileBuilder.addFileComment(fileComment);
    }

    javaFileBuilder.addFileComment("\nGenerated by Motif. Do Not Edit!\n");

    JavaFile javaFile = javaFileBuilder.build();
    return javaFile;
  }
613653
@Override
	public void generate(TypeSpec.Builder classBuilder, boolean mapFields, SQLiteModelMethod method) {
		Set<JQLProjection> fieldList = JQLChecker.getInstance().extractProjections(method, method.jql.value, method.getEntity());

		// generate method code
		MethodSpec.Builder methodBuilder = generateMethodBuilder(method);

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

		if (!method.isPagedLiveData()) {
			// method ForLiveData do not have to be generated for paged live
			// data
			classBuilder.addMethod(methodBuilder.build());
		}

	}
732541
@Override
    public Serializable generateKey(final MethodInvocation methodInvocation) {
        //Determine the tareted CachableMethod
        final CachableMethod cachableMethod = this.resolveCacheableMethod(methodInvocation);

        //Use the resolved cachableMethod to determine the seed Map and then get the hash of the key elements
        final Object[] methodArguments = methodInvocation.getArguments();
        final Map<String, Object> seed = this.getSeed(methodArguments, cachableMethod);
        final Integer keyHashCode = this.getKeyHash(seed);

        //If no code generated return null
        if (keyHashCode == null) {
            if (this.logger.isDebugEnabled()) {
                this.logger.debug("No cache key generated for MethodInvocation='" + methodInvocation + "'");
            }
            return null;
        }

        //Calculate the hashCode and checkSum
        final HashCodeCalculator hashCodeCalculator = new HashCodeCalculator();
        hashCodeCalculator.append(keyHashCode);

        //Assemble the serializable key object
        final long checkSum = hashCodeCalculator.getCheckSum();
        final int hashCode = hashCodeCalculator.getHashCode();
        final HashCodeCacheKey hashCodeCacheKey = new HashCodeCacheKey(checkSum, hashCode);

        if (this.logger.isDebugEnabled()) {
            this.logger.debug("Generated cache key '" + hashCodeCacheKey + "' for MethodInvocation='" + methodInvocation + "'");
        }
        return hashCodeCacheKey;
    }
281832
public static void generateSQL(final SQLiteModelMethod method, MethodSpec.Builder methodBuilder) {
		JQLChecker jqlChecker = JQLChecker.getInstance();

		methodBuilder.addCode("\n// generate sql\n");
		String sql = jqlChecker.replace(method, method.jql, new JQLReplacerListenerImpl(method) {
			@Override
			public String onColumnNameToUpdate(String columnName) {
				// only entity's columns
				return currentEntity.findPropertyByName(columnName).columnName;
			}

			@Override
			public String onColumnName(String columnName) {
				return currentSchema.findColumnNameByPropertyName(method, columnName);
			}

			@Override
			public String onBindParameter(String bindParameterName, boolean inStatement) {
				return "?";
			}

		});

		if (method.jql.dynamicReplace.containsKey(JQLDynamicStatementType.DYNAMIC_WHERE)) {
			methodBuilder.addStatement("String _sql=String.format($S, $L)",
					sql.replace(method.jql.dynamicReplace.get(JQLDynamicStatementType.DYNAMIC_WHERE), "%s"),
					"StringUtils.ifNotEmptyAppend(_sqlDynamicWhere,\" AND \")");
		} else {
			methodBuilder.addStatement("String _sql=$S", sql);
		}
	}
1249919
public String[] getGeneratorFunctions()
    {
    String[] functions = new String[ generators_.size()];
    generators_.keySet().toArray( functions);
    return functions;
    }
679985
public static void generateSelect(Builder builder, SQLiteModelMethod method) throws ClassNotFoundException {
		SelectType selectResultType = SelectBuilderUtility.detectSelectType(method);

		// generate select method
		selectResultType.generate(builder, method);

		if (method.hasLiveData()) {
			// generate
			selectResultType.generateLiveData(builder, method);
		}

		if (method.contentProviderEntryPathEnabled) {
			// we need to generate UPDATE or DELETE for content provider to
			generateSelectForContentProvider(builder, method, selectResultType);
		}
	}
840380
public Object[] getMethods() {
        Method[] methods = getClassUnderInspection().getMethods();
        Constructor[] ctors = getClassUnderInspection().getConstructors();
        Object[] result = new Object[methods.length + ctors.length];
        int resultIndex = 0;
        for (; resultIndex < methods.length; resultIndex++) {
            Method method = methods[resultIndex];
            result[resultIndex] = methodInfo(method);
        }
        for (int i = 0; i < ctors.length; i++, resultIndex++) {
            Constructor ctor = ctors[i];
            result[resultIndex] = methodInfo(ctor);
        }
        return result;
    }