@Override public Object invoke(Object target, Object[] params, IRuntimeEnv env) { return invokeInner(target, params, env); } };
@Override public void addMethod(IOpenMethod candidate) { super.addMethod(candidate); candidatesSorted = null; }
@Override public List<IOpenMethod> getCandidates() { if (candidatesSorted == null) { candidatesSorted = prioritySorter.sort(super.getCandidates()); } return candidatesSorted; }
private IOpenMethod getMethodFromDispatcher(OpenMethodDispatcher method, TableSyntaxNode syntaxNode) { List<IOpenMethod> candidates = method.getCandidates(); for (IOpenMethod candidate : candidates) { IOpenMethod resolvedMethod = resolveMethod(candidate, syntaxNode); if (resolvedMethod != null) { return resolvedMethod; } } return null; }
static ATableTracerNode create(OpenMethodDispatcher dispatcher, Object[] params, IRuntimeContext context) { ExecutableRulesMethod method = (ExecutableRulesMethod) dispatcher.getDispatcherTable().getMember(); return new OverloadedMethodChoiceTraceObject(method, params, context, dispatcher.getCandidates()); } }
private void validateTestSuiteMethod(IOpenMethod method, IOpenMethod existedMethod) { if (method instanceof IUriMember && existedMethod instanceof IUriMember) { if (!UriMemberHelper.isTheSame((IUriMember) method, (IUriMember) existedMethod)) { String message = ValidationMessages.getDuplicatedMethodMessage(existedMethod, method); addDuplicatedMethodError(message, method, existedMethod); } } else { throw new IllegalStateException("Implementation supports only IUriMember!"); } }
@Override public IOpenClass getType() { //Use types from declaring types. For customspreadsheetresult types. IOpenClass type = getDeclaringClass().findType(super.getType().getName()); if (type == null){ return super.getType(); } return type; }
@Override public IOpenMethod findMatchingMethod(IRuntimeEnv env) { IOpenMethod openMethod = WrapperLogic.getTopClassMethod(this, env); return ((OpenMethodDispatcher) openMethod).findMatchingMethod(env); }
private IOpenMethod getMethodFromDispatcher(OpenMethodDispatcher method, TableSyntaxNode syntaxNode) { List<IOpenMethod> candidates = method.getCandidates(); for (IOpenMethod candidate : candidates) { IOpenMethod resolvedMethod = resolveMethod(candidate, syntaxNode); if (resolvedMethod != null) { return resolvedMethod; } } return null; }
static ATableTracerNode create(OpenMethodDispatcher dispatcher, Object[] params, IRuntimeContext context) { ExecutableRulesMethod method = (ExecutableRulesMethod) dispatcher.getDispatcherTable().getMember(); return new OverloadedMethodChoiceTraceObject(method, params, context, dispatcher.getCandidates()); } }
@Override public String getUri() { if (getOriginal() instanceof IUriMember) { return ((IUriMember) getOriginal()).getUri(); } else { throw new IllegalStateException("Implementation doesn't support methods other than ExecutableRulesMethod!"); } }
@Override public IOpenMethod findMatchingMethod(IRuntimeEnv env) { IOpenMethod openMethod = WrapperLogic.getTopClassMethod(this, env); return ((OpenMethodDispatcher) openMethod).findMatchingMethod(env); }
private IOpenMethod resolveMethodDispatcher(OpenMethodDispatcher method, TableSyntaxNode syntaxNode) { List<IOpenMethod> candidates = method.getCandidates(); for (IOpenMethod candidate : candidates) { IOpenMethod resolvedMethod = resolveMethod(candidate, syntaxNode); if (resolvedMethod != null) { return method; } } return null; }
@Override public String getUri() { if (getOriginal() instanceof IUriMember) { return ((IUriMember) getOriginal()).getUri(); } else { throw new IllegalStateException("Implementation doesn't support methods other than ExecutableRulesMethod!"); } }
/** * Invokes appropriate method using runtime context. */ protected Object invokeInner(Object target, Object[] params, IRuntimeEnv env) { IOpenMethod method = findMatchingMethod(env); Tracer.put(this, "rule", method); return method.invoke(target, params, env); }
private IOpenMethod resolveMethodDispatcher(OpenMethodDispatcher method, TableSyntaxNode syntaxNode) { List<IOpenMethod> candidates = method.getCandidates(); for (IOpenMethod candidate : candidates) { IOpenMethod resolvedMethod = resolveMethod(candidate, syntaxNode); if (resolvedMethod != null) { return resolvedMethod; } } return null; }
private IOpenMethod resolveMethodDispatcher(OpenMethodDispatcher method, TableSyntaxNode syntaxNode) { List<IOpenMethod> candidates = method.getCandidates(); for (IOpenMethod candidate : candidates) { IOpenMethod resolvedMethod = resolveMethod(candidate, syntaxNode); if (resolvedMethod != null) { return resolvedMethod; } } return null; }
private static void extractMethods(Collection<IOpenMethod> methods, List<IOpenMethod> result) { for (IOpenMethod method : methods) { if (method instanceof OpenMethodDispatcher) { extractMethods(((OpenMethodDispatcher) method).getCandidates(), result); } else { result.add(method); } } }
@Override public void addMethodDependency(IOpenMethod method, IBoundNode node) { getMethodsMap().put(method, node); // check if method is instance of Openl executable rules method. if (method instanceof ExecutableMethod) { getRulesMethodsMap().put((ExecutableMethod)method, node); } else if (method instanceof OpenMethodDispatcher) { List<IOpenMethod> overlappedMethods =((OpenMethodDispatcher)method).getCandidates(); for (IOpenMethod overlappedMethod : overlappedMethods) { addMethodDependency(overlappedMethod, node); } } }