private void checkDuplicateFunctionExist(FunctionDefinition functionDefinition) { if (this.functionDefinitionMap.get(functionDefinition.getId()) != null) { throw new DuplicateDefinitionException("The function definition with the same id exists " + functionDefinition.getId(), functionDefinition.getQueryContextStartIndex(), functionDefinition.getQueryContextEndIndex()); } }
public void defineFunction(FunctionDefinition functionDefinition) { if (functionDefinition == null) { throw new SiddhiAppValidationException("Function Definition should not be null"); } else if (functionDefinition.getId() == null) { throw new SiddhiAppValidationException("Function Id should not be null for Function Definition", functionDefinition.getQueryContextStartIndex(), functionDefinition.getQueryContextEndIndex()); } else if (functionDefinition.getReturnType() == null) { throw new SiddhiAppValidationException("Return type should not be null for Function Definition", functionDefinition.getQueryContextStartIndex(), functionDefinition.getQueryContextEndIndex()); } else if (functionDefinition.getBody() == null) { throw new SiddhiAppValidationException("Body should not be null for Function Definition", functionDefinition.getQueryContextStartIndex(), functionDefinition.getQueryContextEndIndex()); } else if (functionDefinition.getLanguage() == null) { throw new SiddhiAppValidationException("Language should not be null for Function Definition", functionDefinition.getQueryContextStartIndex(), functionDefinition.getQueryContextEndIndex()); } checkDuplicateFunctionExist(functionDefinition); this.functionDefinitionMap.put(functionDefinition.getId(), functionDefinition); }
private void checkDuplicateFunctionExist(FunctionDefinition functionDefinition) { if (this.functionDefinitionMap.get(functionDefinition.getId()) != null) { throw new DuplicateDefinitionException("The function definition with the same id exists " + functionDefinition.getId(), functionDefinition.getQueryContextStartIndex(), functionDefinition.getQueryContextEndIndex()); } }
/** * obtains information of all the user defined Functions. */ private void loadFunctionData(SiddhiApp siddhiApp, List<OutputAttribute> functionList, SiddhiAppElements siddhiAppElements, String appData) { for (FunctionDefinition functionDefinition : siddhiApp.getFunctionDefinitionMap().values()) { for (OutputAttribute app : functionList) { if (app.getExpression() instanceof AttributeFunction) { if (functionDefinition.getId().equals(((AttributeFunction) app.getExpression()).getName())) { String functionDefinitionStr = getDefinition(functionDefinition, appData); siddhiAppElements.setFunction(functionDefinition.getId()); siddhiAppElements.setFunctionQuery(functionDefinitionStr); break; } } } } }
/** * Generates FunctionConfig from the given Siddhi FunctionDefinition * * @param functionDefinition Siddhi FunctionDefinition * @return FunctionConfig object */ public FunctionConfig generateFunctionConfig(FunctionDefinition functionDefinition) { FunctionConfig functionConfig = new FunctionConfig(functionDefinition.getId(), functionDefinition.getLanguage(), functionDefinition.getReturnType().toString(), functionDefinition.getBody()); preserveAndBindCodeSegment(functionDefinition, functionConfig); return functionConfig; } }
public void defineFunction(FunctionDefinition functionDefinition) { if (functionDefinition == null) { throw new SiddhiAppValidationException("Function Definition should not be null"); } else if (functionDefinition.getId() == null) { throw new SiddhiAppValidationException("Function Id should not be null for Function Definition", functionDefinition.getQueryContextStartIndex(), functionDefinition.getQueryContextEndIndex()); } else if (functionDefinition.getReturnType() == null) { throw new SiddhiAppValidationException("Return type should not be null for Function Definition", functionDefinition.getQueryContextStartIndex(), functionDefinition.getQueryContextEndIndex()); } else if (functionDefinition.getBody() == null) { throw new SiddhiAppValidationException("Body should not be null for Function Definition", functionDefinition.getQueryContextStartIndex(), functionDefinition.getQueryContextEndIndex()); } else if (functionDefinition.getLanguage() == null) { throw new SiddhiAppValidationException("Language should not be null for Function Definition", functionDefinition.getQueryContextStartIndex(), functionDefinition.getQueryContextEndIndex()); } checkDuplicateFunctionExist(functionDefinition); this.functionDefinitionMap.put(functionDefinition.getId(), functionDefinition); }