@Override protected IOpenMethod findMatchingMethod(List<IOpenMethod> candidates, IRuntimeContext context) { Set<IOpenMethod> selected = new HashSet<IOpenMethod>(candidates); selectCandidates(selected, (IRulesRuntimeContext) context); maxMinSelectCandidates(selected, (IRulesRuntimeContext) context); switch (selected.size()) { case 0: IOpenMethod candidateMethod = candidates.iterator().next(); throw new OpenLRuntimeException( String.format("No matching methods with name '%3$s' for the context. Details: \n%1$s\nContext: %2$s", toString(candidates), context.toString(), candidateMethod.getName())); case 1: IOpenMethod matchingMethod = selected.iterator().next(); return matchingMethod; default: IOpenMethod method = selected.iterator().next(); throw new OpenLRuntimeException( String.format("Ambiguous dispatch for method '%3$s'. Details: \n%1$s\nContext: %2$s", toString(selected), context.toString(), method.getName())); } }