protected Map.Entry<String, Pattern> getRegexEntry(String id) {
    Map.Entry<String, Pattern> regexEntry = null;

    for (Map.Entry<String, Pattern> entry : patterns.entrySet()) {
      Pattern pattern = entry.getValue();
      Matcher matcher = pattern.matcher(id);

      if (matcher.matches()) {
        String key = entry.getKey();
        if (regexEntry == null || key.startsWith(regexEntry.getKey())) {
          regexEntry = entry;
        }
      }
    }
    return regexEntry;
  }
Gets the key/value mapping between a metric string in the JSON files and
the Java regular expression pattern that matches it.

@param id
@return the entry, or {@code null} if none match the ID.
ambari-server/src/main/java/org/apache/ambari/server/controller/internal/BaseProvider.java