code: private <T> Collection<T> checkIfClassNamesMatchKey(Collection<ServiceReference<T>> references, String key) {
      Set<T> result = new HashSet<T>();
      for (ServiceReference<T> ref : references) {
        T service = getBundleContext().getService(ref);
        if (service != null) {
          String keyWithFirstLetterUppercase = Character.toUpperCase(key.charAt(0)) + key.substring(1);
          if (service.getClass().getSimpleName().equals(keyWithFirstLetterUppercase)) {
            result.add(service);
          }
        }
      }
      return result;
    }
docs: Gets the service objects from the {@link BundleContext} and compares the
  class names to the given key. For the comparison see
  {@link #checkRegisteredOsgiServices(String, String)}.
  
  @param references
  @param key
  @return