Exemple #1
0
 private NaturalLanguageMethodMatch match(
     NaturalLanguageMethod naturalLanguageMethod, String inputString) {
   if (LOGGER.isLoggable(Level.FINEST)) {
     LOGGER.log(
         Level.FINEST,
         "Checking "
             + naturalLanguageMethod.getPattern()
             + " for match with '"
             + inputString
             + "'");
   }
   Matcher matcher = naturalLanguageMethod.getPattern().matcher(inputString);
   if (matcher.matches()) {
     return new NaturalLanguageMethodMatch(naturalLanguageMethod, matcher);
   }
   return null;
 }
Exemple #2
0
 Object invokeMethod(Object objectToInvoke) {
   Method method = getNaturalLanguageMethod().getMethod();
   List<ArgumentConverter> argumentConverters = naturalLanguageMethod.getArgumentConverters();
   Object[] args = new Object[matcher.groupCount()];
   for (int i = 0; i < matcher.groupCount(); i++) {
     String group = matcher.group(i + 1);
     args[i] = argumentConverters.get(i).convertArgument(group, naturalLanguageMethod, i);
   }
   return ReflectionUtil.invokeWithArgs(method, objectToInvoke, args);
 }
Exemple #3
0
 private boolean isCatchAllMethod(NaturalLanguageMethod method) {
   return method.getPattern().pattern().equals(EVERYTHING_ELSE_REGEX);
 }