use of org.eclipse.vorto.mapping.engine.functions.IScriptEvalProvider in project vorto by eclipse.
the class MappingSpecification method getScriptFunctions.
@Override
public FunctionLibrary getScriptFunctions(IScriptEvalProvider factory) {
FunctionLibrary library = new FunctionLibrary();
this.infoModel.getFunctionblocks().stream().forEach(property -> {
IMappedElement mappedElement = (IMappedElement) property.getType();
if (mappedElement.getStereotype(STEREOTYPE_FUNCTIONS).isPresent()) {
Stereotype functionsStereoType = mappedElement.getStereotype(STEREOTYPE_FUNCTIONS).get();
IScriptEvaluator evaluator = factory.createEvaluator(property.getName().toLowerCase());
functionsStereoType.getAttributes().keySet().stream().filter(functionName -> !functionName.equalsIgnoreCase(STEREOTYPE_NAMESPACE)).forEach(functionName -> evaluator.addScriptFunction(new ScriptClassFunction(functionName, functionsStereoType.getAttributes().get(functionName))));
library.addFunctions(evaluator.getFunctions());
}
});
return library;
}
Aggregations