classText.append("public class UpdateCheckerFormulaImpl extends UpdateCheckerFormula{\n");
classText.append("\tpublic int mainCompare(String currentVersion,String latestVersion){\n");
classText.append("\t\t").append(formulaDef).append('\n');
classText.append("\t}\n");
classText.append("}\n");
GroovyClassLoader loader = new GroovyClassLoader(UpdateChecker.class.getClassLoader());
try {
Class groovyClass = loader.parseClass(classText.toString()); //TODO this his horribly slow (~500ms) Can we parse all at once or can we do this lazily or initialize in another thread?
return (UpdateCheckerFormula)groovyClass.newInstance();
} catch (Exception e) {
return new UpdateCheckerFormula();
}
}