@NotThreadSafe public static final class MongoClientSettings.Builder extends Object
MongoClientSettings
so that MongoClientSettings
can be immutable, and to support easier construction
through chaining.public MongoClientSettings.Builder applyConnectionString(ConnectionString connectionString)
ConnectionString
and applies them to the builderconnectionString
- the connection string containing details of how to connect to MongoDBpublic MongoClientSettings.Builder applyToClusterSettings(Block<ClusterSettings.Builder> block)
ClusterSettings.Builder
block and then sets the clusterSettings.block
- the block to apply to the ClusterSettings.MongoClientSettings.getClusterSettings()
public MongoClientSettings.Builder applyToSocketSettings(Block<SocketSettings.Builder> block)
SocketSettings.Builder
block and then sets the socketSettings.block
- the block to apply to the SocketSettings.MongoClientSettings.getSocketSettings()
public MongoClientSettings.Builder applyToConnectionPoolSettings(Block<ConnectionPoolSettings.Builder> block)
ConnectionPoolSettings.Builder
block and then sets the connectionPoolSettings.block
- the block to apply to the ConnectionPoolSettings.MongoClientSettings.getConnectionPoolSettings()
public MongoClientSettings.Builder applyToServerSettings(Block<ServerSettings.Builder> block)
ServerSettings.Builder
block and then sets the serverSettings.block
- the block to apply to the ServerSettings.MongoClientSettings.getServerSettings()
public MongoClientSettings.Builder applyToSslSettings(Block<SslSettings.Builder> block)
SslSettings.Builder
block and then sets the sslSettings.block
- the block to apply to the SslSettings.MongoClientSettings.getSslSettings()
@Deprecated public MongoClientSettings.Builder clusterSettings(ClusterSettings clusterSettings)
applyToClusterSettings(Block)
clusterSettings
- the cluster settingsMongoClientSettings.getClusterSettings()
@Deprecated public MongoClientSettings.Builder socketSettings(SocketSettings socketSettings)
applyToSocketSettings(Block)
socketSettings
- the socket settingsMongoClientSettings.getSocketSettings()
@Deprecated public MongoClientSettings.Builder heartbeatSocketSettings(SocketSettings heartbeatSocketSettings)
heartbeatSocketSettings
- the socket settingsMongoClientSettings.getHeartbeatSocketSettings()
@Deprecated public MongoClientSettings.Builder connectionPoolSettings(ConnectionPoolSettings connectionPoolSettings)
applyToConnectionPoolSettings(Block)
connectionPoolSettings
- the connection settings()
@Deprecated public MongoClientSettings.Builder serverSettings(ServerSettings serverSettings)
applyToServerSettings(Block)
serverSettings
- the server settings()
@Deprecated public MongoClientSettings.Builder sslSettings(SslSettings sslSettings)
applyToSslSettings(Block)
sslSettings
- the SSL settings()
public MongoClientSettings.Builder readPreference(ReadPreference readPreference)
readPreference
- read preferenceMongoClientSettings.getReadPreference()
public MongoClientSettings.Builder writeConcern(WriteConcern writeConcern)
writeConcern
- the write concernMongoClientSettings.getWriteConcern()
public MongoClientSettings.Builder retryWrites(boolean retryWrites)
retryWrites
- sets if writes should be retried if they fail due to a network error.MongoClientSettings.getRetryWrites()
public MongoClientSettings.Builder readConcern(ReadConcern readConcern)
readConcern
- the read concern@Deprecated public MongoClientSettings.Builder credentialList(List<MongoCredential> credentialList)
credential(MongoCredential)
credentialList
- the credential listMongoClientSettings.getCredentialList()
public MongoClientSettings.Builder credential(MongoCredential credential)
credential
- the credentialMongoClientSettings.getCredential()
public MongoClientSettings.Builder codecRegistry(CodecRegistry codecRegistry)
codecRegistry
- the codec registryMongoClientSettings.getCodecRegistry()
public MongoClientSettings.Builder streamFactoryFactory(StreamFactoryFactory streamFactoryFactory)
StreamFactory
.streamFactoryFactory
- the stream factory factorypublic MongoClientSettings.Builder addCommandListener(CommandListener commandListener)
commandListener
- the command listenerpublic MongoClientSettings.Builder applicationName(String applicationName)
applicationName
- the logical name of the application using this MongoClient. It may be null.
The UTF-8 encoding may not exceed 128 bytes.MongoClientSettings.getApplicationName()
public MongoClientSettings.Builder compressorList(List<MongoCompressor> compressorList)
public MongoClientSettings build()
MongoClientSettings
.