public List<FunctionDef> getFunctions(String functionName) { return registry.stream() .filter(functionDef -> functionDef.getName().equals(functionName)) .collect(collectingAndThen(Collectors.toList(), Collections::unmodifiableList)); }
private void setFunctions(List<FunctionDef> functions) { currentFunctions = functions.stream().collect(Collectors.toMap(FunctionDef::getName, Function.identity())); options = functions.stream().collect(Collectors.toMap(FunctionDef::getName, functionDef -> functionNamingService.getFunctionName(functionDef.getName()))); } }
private String parseFunctionName() throws ParseException { int index = nextNonBlank(); if (index < 0 || !expression.startsWith(KIE_FUNCTIONS, index)) { throw new ParseException(errorMessage(FUNCTION_CALL_NOT_FOUND_ERROR), parseIndex); } for (FunctionDef functionDef : FunctionsRegistry.getInstance().getFunctions()) { if (expression.startsWith(KIE_FUNCTIONS + functionDef.getName(), index)) { functionName = KIE_FUNCTIONS + functionDef.getName(); break; } } if (functionName == null) { throw new ParseException(errorMessage(VALID_FUNCTION_CALL_NOT_FOUND_ERROR, functionNames()), parseIndex); } setParseIndex(index + functionName.length()); return functionName; }
private void testFindAvailableFunctions(String clazz, String[] expectedFunctions) { List<FunctionDef> functionDefs = service.findAvailableFunctions(path, clazz); assertEquals(functionDefs.size(), expectedFunctions.length); for (String expectedFunction : expectedFunctions) { assertTrue(functionDefs.stream() .anyMatch(functionDef -> expectedFunction.equals(functionDef.getName()))); } }
private void initParams(String function, List<String> paramValues) { removeParams(); Map<Integer, String> paramValue = new HashMap<>(); if (paramValues != null) { for (int i = 0; i < paramValues.size(); i++) { paramValue.put(i, paramValues.get(i)); } } FunctionDef functionDef = functionSearchService.getFunction(function); ParamDef paramDef; for (int i = 1; i < functionDef.getParams().size(); i++) { paramDef = functionDef.getParams().get(i); ConditionParamPresenter param = newParamPresenter(); currentParams.add(param); param.setName(functionNamingService.getParamName(functionDef.getName(), paramDef.getName())); param.setHelp(functionNamingService.getParamHelp(functionDef.getName(), paramDef.getName())); param.setValue(paramValue.get(i)); view.addParam(param.getView().getElement()); param.setOnChangeCommand(this::onParamChange); } }