docs: public final B profile(ClassLoader classLoader, Iterable<String> profiles) {
          requireNonNull(classLoader, "classLoader");
          requireNonNull(profiles, "profiles");
          checkState(selectedProfile == null, "profile cannot be loaded more than once.");
          checkState(hosts.isEmpty(), "profile() and host() cannot be used together.");
  
          final Map<String, ClientProfile> availableProfiles = new HashMap<>();
          try {
              final List<URL> resourceUrls = findProfileResources(classLoader);
              checkState(!resourceUrls.isEmpty(), "failed to find any of: ", profileResourcePaths);
  
              for (URL resourceUrl : resourceUrls) {
                  final List<ClientProfile> availableProfileList =
                          new ObjectMapper().readValue(resourceUrl, new TypeReference<List<ClientProfile>>() {});
  
                  // Collect all profiles checking the profiles ignoring the duplicate profile names.
                  availableProfileList.forEach(profile -> {
                      final String name = profile.name();
                      final ClientProfile existingProfile = availableProfiles.get(name);
                      if (existingProfile == null || existingProfile.priority() < profile.priority()) {
                          // Not a duplicate or higher priority
                          availableProfiles.put(name, profile);
                      }
                  });
              }
          } catch (IOException e) {
              throw new IllegalStateException("failed to load: " + PROFILE_RESOURCE_PATH, e);
          }
  
          final List<String> reversedProfiles = reverse(profiles);
          checkArgument(!reversedProfiles.isEmpty(), "profiles is empty.");
          for (String candidateName : reversedProfiles) {
              checkNotNull(candidateName, "profiles contains null: %s", profiles);
  
              final ClientProfile candidate = availableProfiles.get(candidateName);
              if (candidate == null) {
                  continue;
              }
  
              final ImmutableSet.Builder<InetSocketAddress> newHostsBuilder = ImmutableSet.builder();
              candidate.hosts().stream()
                       .filter(e -> (useTls ? "https" : "http").equals(e.protocol()))
                       .forEach(e -> newHostsBuilder.add(newEndpoint(e.host(), e.port())));
  
              final ImmutableSet<InetSocketAddress> newHosts = newHostsBuilder.build();
              if (!newHosts.isEmpty()) {
                  selectedProfile = candidateName;
                  hosts = newHosts;
                  return self();
              }
          }
  
          throw new IllegalArgumentException("no profile matches: " + profiles);
      }