use of com.googlecode.aviator.runtime.function.ClassMethodFunction in project aviatorscript by killme2008.
the class Reflector method retrieveStaticFunction.
private static PropertyFoundResult retrieveStaticFunction(final Map<String, PropertyFoundResult> results, final Class<?> clazz, final String name) throws IllegalAccessException, NoSuchMethodException {
PropertyFoundResult result;
List<Method> methods = getStaticMethods(clazz, name);
if (methods != null && !methods.isEmpty()) {
// cast the methods into a function.
ClassMethodFunction func = new ClassMethodFunction(clazz, true, name, name, methods);
result = new PropertyFoundResult(func);
} else {
result = new PropertyFoundResult(null);
}
results.put(name, result);
return result;
}
use of com.googlecode.aviator.runtime.function.ClassMethodFunction in project aviatorscript by killme2008.
the class AviatorEvaluatorInstance method loadModule.
private Env loadModule(final Class<?> moduleClazz) throws IllegalAccessException, NoSuchMethodException {
Map<String, List<Method>> methodMap = findMethodsFromClass(moduleClazz, true);
if (methodMap == null || methodMap.isEmpty()) {
throw new IllegalArgumentException("Empty module");
}
Env exports = new Env();
for (Map.Entry<String, List<Method>> entry : methodMap.entrySet()) {
exports.put(entry.getKey(), new ClassMethodFunction(moduleClazz, true, entry.getKey(), entry.getKey(), entry.getValue()));
}
exports.setInstance(this);
return exports;
}
use of com.googlecode.aviator.runtime.function.ClassMethodFunction in project aviatorscript by killme2008.
the class AviatorEvaluatorInstance method addMethodFunctions.
private List<String> addMethodFunctions(final String namespace, final boolean isStatic, final Class<?> clazz) throws IllegalAccessException, NoSuchMethodException {
Map<String, List<Method>> methodMap = findMethodsFromClass(clazz, isStatic);
List<String> added = new ArrayList<>();
for (Map.Entry<String, List<Method>> entry : methodMap.entrySet()) {
String methodName = entry.getKey();
String name = namespace + "." + methodName;
this.addFunction(new ClassMethodFunction(clazz, isStatic, name, methodName, entry.getValue()));
added.add(name);
}
return added;
}
Aggregations