@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()
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 concernpublic MongoClientSettings.Builder credential(MongoCredential credential)
credential
- the credentialpublic 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 commandListenerList(List<CommandListener> commandListeners)
commandListeners
- the list of command listenerspublic MongoClientSettings.Builder applicationName(@Nullable 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)
compressorList
- the list of compressors to requestMongoClientSettings.getCompressorList()
public MongoClientSettings build()
MongoClientSettings
.