@Nullable
    public MongoCredential getCredential() {
        if (getCredentialsList().size() > 1) {
            throw new IllegalStateException("Instance constructed with more than one MongoCredential");
        } else if (getCredentialsList().isEmpty()) {
            return null;
        } else {
            return getCredentialsList().get(0);
        }
    }
@Nullable
    public MongoCredential getCredential() {
        if (getCredentialsList().size() > 1) {
            throw new IllegalStateException("Instance constructed with more than one MongoCredential");
        } else if (getCredentialsList().isEmpty()) {
            return null;
        } else {
            return getCredentialsList().get(0);
        }
    }
@ Nullable public MongoCredential getCredential ( ) { if ( getCredentialsList ( ) . size ( ) > 1 ) { throw new IllegalStateException ( "Instance constructed with more than one MongoCredential" ) ; } else if ( getCredentialsList ( ) . isEmpty ( ) ) { return null ; } else { return getCredentialsList ( ) . get ( 0 ) ; } }
Gets the credential that this client authenticates all connections with

@return the credential, which may be null in unsecured deployments
@since 3.9
Gets the credential that this client authenticates all connections with