code: public static Credentials checkValidForProvider(Credentials creds,
                                                    denominator.Provider provider) {
      checkNotNull(provider, "provider cannot be null");
      if (isAnonymous(creds) && provider.credentialTypeToParameterNames().isEmpty()) {
        return AnonymousCredentials.INSTANCE;
      } else if (creds instanceof Map) {
        // check Map first as clojure Map implements List Map.Entry
        if (credentialConfigurationHasKeys(provider, Map.class.cast(creds).keySet())) {
          return creds;
        }
      } else if (creds instanceof List) {
        if (credentialConfigurationHasPartCount(provider, List.class.cast(creds).size())) {
          return creds;
        }
      }
      throw new IllegalArgumentException(exceptionMessage(creds, provider));
    }
docs: checks that the supplied input is valid, or throws an {@code IllegalArgumentException} if not.
  Users of this are guaranteed that the {@code input} matches the count of parameters of a
  credential type listed in {@link denominator.Provider#credentialTypeToParameterNames()}.
  
  <br> <br> <b>Coercion to {@code AnonymousCredentials}</b><br>
  
  if {@link denominator.Provider#credentialTypeToParameterNames()} is empty, then no credentials
  are required. When this is true, the following cases will return {@code AnonymousCredentials}.
  <ul> <li>when {@code input} is null</li> <li>when {@code input} is an instance of {@code
  AnonymousCredentials}</li> <li>when {@code input} is an empty instance of {@code Map} or {@code
  List}</li> </ul>
  
  <br> <br> <b>Validation Rules</b><br>
  
  See {@link Credentials} for Validation Rules
  
  @param creds    nullable credentials to test
  @param provider context which helps create a useful error message on failure.
  @return correct Credentials value which can be {@link AnonymousCredentials} if {@code input}
  was null and credentials are not needed.
  @throws IllegalArgumentException if provider requires a different amount of credential parts
  than {@code input}