code: public Set<DiscoveryEntryWithMetaInfo> filter(Version callerVersion,
                                                    Set<DiscoveryEntryWithMetaInfo> discoveryEntries,
                                                    Map<String, Set<Version>> discoveredVersions) {
          if (callerVersion == null || discoveryEntries == null) {
              throw new IllegalArgumentException(String.format("Neither callerVersion (%s) nor discoveryEntries (%s) can be null.",
                                                               callerVersion,
                                                               discoveryEntries));
          }
          Iterator<DiscoveryEntryWithMetaInfo> iterator = discoveryEntries.iterator();
          while (iterator.hasNext()) {
              DiscoveryEntry discoveryEntry = iterator.next();
              if (discoveredVersions != null) {
                  Set<Version> versionsByDomain = discoveredVersions.get(discoveryEntry.getDomain());
                  if (versionsByDomain == null) {
                      versionsByDomain = new HashSet<>();
                      discoveredVersions.put(discoveryEntry.getDomain(), versionsByDomain);
                  }
                  versionsByDomain.add(discoveryEntry.getProviderVersion());
              }
              if (!versionCompatibilityChecker.check(callerVersion, discoveryEntry.getProviderVersion())) {
                  iterator.remove();
              }
          }
          return discoveryEntries;
      }
docs: Reduces the passed in set of {@link DiscoveryEntry discovery entries} by
  removing all of those entries which are incompatible with the specified
  caller {@link Version}.
  
  @param callerVersion the version of the caller. Must not be <code>null</code>.
  @param discoveryEntries the discovery entries which are to be filtered by versions.
  Must not be <code>null</code>.
  @param discoveredVersions a container into which the method will write all
  versions it comes across during the filtering keyed by the domain for which the version was found.
  Mainly provided so that the iteration only occurs once.
  If <code>null</code>, then it is ignored.
  
  @return the filtered discovery entry set.