/** * Finds and invokes a count method whose name is given by countMethod and whose signature * includes one String, and any number of boolean or Booleans * * @param service * @param query * @param context * @return */ private int doCount(OpenmrsService service, String query, RequestContext context) { try { for (Method candidate : serviceClass.getMethods()) { if (candidate.getName().equals(countMethod) && hasRightParameterTypes(candidate, 1, 0)) { return invokeCountMethod(service, candidate, query, context); } } } catch (Exception ex) { throw new RuntimeException(countMethod + " failed", ex); } throw new RuntimeException("Cannot find suitable method"); }