Remove unused methods in compiled functions
This commit is contained in:
@@ -58,12 +58,6 @@ public abstract class AbstractFunctionCompiler<F> {
|
|||||||
+ " public %s<%s> getResult() {\n"
|
+ " public %s<%s> getResult() {\n"
|
||||||
+ " %s\n"
|
+ " %s\n"
|
||||||
+ " }\n"
|
+ " }\n"
|
||||||
+ " public String getInputType() {\n"
|
|
||||||
+ " return \"%s\";\n"
|
|
||||||
+ " }\n"
|
|
||||||
+ " public String getOutputType() {\n"
|
|
||||||
+ " return \"%s\";\n"
|
|
||||||
+ " }\n"
|
|
||||||
+ "}\n";
|
+ "}\n";
|
||||||
// @formatter:on
|
// @formatter:on
|
||||||
|
|
||||||
@@ -104,8 +98,7 @@ public abstract class AbstractFunctionCompiler<F> {
|
|||||||
}
|
}
|
||||||
logger.info("Initial code property value :'{}'", code);
|
logger.info("Initial code property value :'{}'", code);
|
||||||
String[] parameterizedTypes = (!ObjectUtils.isEmpty(resultTypeParameterizations))
|
String[] parameterizedTypes = (!ObjectUtils.isEmpty(resultTypeParameterizations))
|
||||||
? resultTypeParameterizations
|
? resultTypeParameterizations : this.defaultResultTypeParameterizations;
|
||||||
: this.defaultResultTypeParameterizations;
|
|
||||||
code = decode(code);
|
code = decode(code);
|
||||||
if (code.startsWith("\"") && code.endsWith("\"")) {
|
if (code.startsWith("\"") && code.endsWith("\"")) {
|
||||||
code = code.substring(1, code.length() - 1);
|
code = code.substring(1, code.length() - 1);
|
||||||
@@ -122,7 +115,8 @@ public abstract class AbstractFunctionCompiler<F> {
|
|||||||
CompilationResult compilationResult = buildAndCompileSourceCode(className, code,
|
CompilationResult compilationResult = buildAndCompileSourceCode(className, code,
|
||||||
parameterizedTypes);
|
parameterizedTypes);
|
||||||
if (compilationResult.wasSuccessful()) {
|
if (compilationResult.wasSuccessful()) {
|
||||||
CompiledFunctionFactory<F> factory = new CompiledFunctionFactory<>(className, compilationResult);
|
CompiledFunctionFactory<F> factory = new CompiledFunctionFactory<>(className,
|
||||||
|
compilationResult);
|
||||||
return this.postProcessCompiledFunctionFactory(factory);
|
return this.postProcessCompiledFunctionFactory(factory);
|
||||||
}
|
}
|
||||||
List<CompilationMessage> compilationMessages = compilationResult
|
List<CompilationMessage> compilationMessages = compilationResult
|
||||||
@@ -131,12 +125,15 @@ public abstract class AbstractFunctionCompiler<F> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementing subclasses may override this, e.g. to set the input and/or output types.
|
* Implementing subclasses may override this, e.g. to set the input and/or output
|
||||||
|
* types.
|
||||||
*
|
*
|
||||||
* @param factory the {@link CompiledFunctionFactory} produced by {@link #compile(String, String, String...)}
|
* @param factory the {@link CompiledFunctionFactory} produced by
|
||||||
|
* {@link #compile(String, String, String...)}
|
||||||
* @return the post-processed {@link CompiledFunctionFactory}
|
* @return the post-processed {@link CompiledFunctionFactory}
|
||||||
*/
|
*/
|
||||||
protected CompiledFunctionFactory<F> postProcessCompiledFunctionFactory(CompiledFunctionFactory<F> factory) {
|
protected CompiledFunctionFactory<F> postProcessCompiledFunctionFactory(
|
||||||
|
CompiledFunctionFactory<F> factory) {
|
||||||
return factory;
|
return factory;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -177,25 +174,9 @@ public abstract class AbstractFunctionCompiler<F> {
|
|||||||
*/
|
*/
|
||||||
private String makeSourceClassDefinition(String className, String methodBody,
|
private String makeSourceClassDefinition(String className, String methodBody,
|
||||||
String[] types) {
|
String[] types) {
|
||||||
String inputType = null;
|
|
||||||
String outputType = null;
|
|
||||||
if (ResultType.Supplier.equals(this.resultType)) {
|
|
||||||
outputType = types[0];
|
|
||||||
}
|
|
||||||
else if (ResultType.Consumer.equals(this.resultType)) {
|
|
||||||
inputType = types[0];
|
|
||||||
}
|
|
||||||
else if (ResultType.Function.equals(this.resultType)) {
|
|
||||||
inputType = types[0];
|
|
||||||
outputType = types[1];
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
throw new IllegalStateException("no FunctionType available");
|
|
||||||
}
|
|
||||||
String shortClassName = className.substring(className.lastIndexOf('.') + 1);
|
String shortClassName = className.substring(className.lastIndexOf('.') + 1);
|
||||||
String s = String.format(SOURCE_CODE_TEMPLATE, shortClassName, resultType,
|
String s = String.format(SOURCE_CODE_TEMPLATE, shortClassName, resultType,
|
||||||
resultType, StringUtils.arrayToCommaDelimitedString(types),
|
resultType, StringUtils.arrayToCommaDelimitedString(types), methodBody);
|
||||||
methodBody, inputType, outputType);
|
|
||||||
System.out.println(s);
|
System.out.println(s);
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user