public MongoCredential withMechanism(final AuthenticationMechanism mechanism) {
    """
	Creates a new MongoCredential with the set mechanism. The existing mechanism must be null.
	
	@param mechanism the mechanism to set
	@return the credential
	@since 3.8
    """
        if (this.mechanism != null) {
            throw new IllegalArgumentException("Mechanism already set");
        }
        return new MongoCredential(mechanism, userName, source, password, mechanismProperties);
    }
public MongoCredential withMechanism(final AuthenticationMechanism mechanism) {
        if (this.mechanism != null) {
            throw new IllegalArgumentException("Mechanism already set");
        }
        return new MongoCredential(mechanism, userName, source, password, mechanismProperties);
    }
public MongoCredential withMechanism ( final AuthenticationMechanism mechanism ) { if ( this . mechanism != null ) { throw new IllegalArgumentException ( "Mechanism already set" ) ; } return new MongoCredential ( mechanism , userName , source , password , mechanismProperties ) ; }
Creates a new MongoCredential with the set mechanism. The existing mechanism must be null.

@param mechanism the mechanism to set
@return the credential
@since 3.8
Creates a new MongoCredential with the set mechanism . The existing mechanism must be null .