Пример #1
0
 NaturalLanguageMethodMatch findMatchingNaturalLanguageMethod(
     String languageString,
     MethodRegexAssociation regexAssociation,
     MethodRegexAssociation transformRegexAssociation,
     Scope scope) {
   List<NaturalLanguageMethod> naturalLanguageMethods =
       getNaturalLanguageMethods(regexAssociation, transformRegexAssociation, scope);
   NaturalLanguageMethodMatch defaultMatch = null;
   for (NaturalLanguageMethod naturalLanguageMethod : naturalLanguageMethods) {
     NaturalLanguageMethodMatch match = match(naturalLanguageMethod, languageString);
     if (match != null) {
       NaturalLanguageMethod method = match.getNaturalLanguageMethod();
       if (isCatchAllMethod(method)) {
         defaultMatch = match;
       } else {
         if (LOGGER.isLoggable(DEBUG_LEVEL)) {
           LOGGER.log(
               DEBUG_LEVEL,
               "Found match for '" + languageString + "': " + match.getNaturalLanguageMethod());
         }
         return match;
       }
     }
   }
   if (defaultMatch != null) {
     if (LOGGER.isLoggable(DEBUG_LEVEL)) {
       LOGGER.log(
           DEBUG_LEVEL,
           "Found match for '" + languageString + "': " + defaultMatch.getNaturalLanguageMethod());
     }
   }
   return defaultMatch;
 }
Пример #2
0
 Object invokeMethod(NaturalLanguageMethodMatch match, Method method) {
   Object objectToInvoke = addAndGetComponent(method.getDeclaringClass());
   return match.invokeMethod(objectToInvoke);
 }
Пример #3
0
 Object invokeMethod(NaturalLanguageMethodMatch match) {
   return invokeMethod(match, match.getNaturalLanguageMethod().getMethod());
 }