Class AppConfiguration.Builder
- java.lang.Object
-
- io.realm.mongodb.AppConfiguration.Builder
-
- Enclosing class:
- AppConfiguration
public static class AppConfiguration.Builder extends Object
Builder used to construct instances of aAppConfiguration
in a fluent manner.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description AppConfiguration.Builder
addCustomRequestHeader(String headerName, String headerValue)
Adds an extra HTTP header to append to every request to a Realm Object Server.AppConfiguration.Builder
addCustomRequestHeaders(Map<String,String> headers)
Adds extra HTTP headers to append to every request to a Realm Object Server.AppConfiguration.Builder
appName(String appName)
Sets the apps name.AppConfiguration.Builder
appVersion(String appVersion)
Sets the apps version.AppConfiguration.Builder
authorizationHeaderName(String headerName)
Sets the name of the HTTP header used to send authorization data in when making requests to MongoDB Realm.AppConfiguration.Builder
baseUrl(String baseUrl)
Sets the base url for the MongoDB Realm Application.AppConfiguration
build()
Creates the AppConfiguration.AppConfiguration.Builder
codecRegistry(CodecRegistry codecRegistry)
Set the default codec registry used to encode and decode BSON arguments and results when calling remote RealmFunctions
and accessing a remoteMongoDatabase
.AppConfiguration.Builder
defaultClientResetHandler(SyncSession.ClientResetHandler handler)
Deprecated.AppConfiguration.Builder
defaultSyncClientResetStrategy(DiscardUnsyncedChangesStrategy strategy)
Sets the default sync client reset strategy used by Synced Realms when they report a Client Reset.AppConfiguration.Builder
defaultSyncClientResetStrategy(ManuallyRecoverUnsyncedChangesStrategy strategy)
Sets the default sync client reset strategy used by Synced Realms when they report a Client Reset.AppConfiguration.Builder
defaultSyncErrorHandler(SyncSession.ErrorHandler errorHandler)
Sets the default error handler used by Synced Realms when reporting errors with their session.AppConfiguration.Builder
encryptionKey(byte[] key)
Sets the encryption key used to encrypt user meta data only.AppConfiguration.Builder
httpLogObfuscator(HttpLogObfuscator httpLogObfuscator)
Sets theHttpLogObfuscator
used to keep sensitive information in HTTP requests from being displayed in the logcat.AppConfiguration.Builder
requestTimeout(long time, TimeUnit unit)
Sets the default timeout used by network requests against the MongoDB Realm application.AppConfiguration.Builder
syncRootDirectory(File rootDir)
Configures the root folder containing all files and Realms used when synchronizing data between the device and MongoDB Realm.
-
-
-
Constructor Detail
-
Builder
public Builder(String appId)
Creates an instance of the Builder for the AppConfiguration.- Parameters:
appId
- the application id of the MongoDB Realm Application.
-
-
Method Detail
-
encryptionKey
public AppConfiguration.Builder encryptionKey(@ParametersAreNonnullByDefault byte[] key)
Sets the encryption key used to encrypt user meta data only. Individual Realms needs to useSyncConfiguration.Builder.encryptionKey(byte[])
to make them encrypted.- Parameters:
key
- a 64 byte encryption key.- Throws:
IllegalArgumentException
- if the key is not 64 bytes long.
-
baseUrl
public AppConfiguration.Builder baseUrl(String baseUrl)
Sets the base url for the MongoDB Realm Application. The default value isAppConfiguration.DEFAULT_BASE_URL
.- Parameters:
baseUrl
- the base url for the MongoDB Realm application.
-
appName
public AppConfiguration.Builder appName(String appName)
Sets the apps name. This is only used as part of debug headers sent when making network requests at the MongoDB Realm application.- Parameters:
appName
- app name used to identify the application.
-
appVersion
public AppConfiguration.Builder appVersion(String appVersion)
Sets the apps version. This is only used as part of debug headers sent when making network requests at the MongoDB Realm application.- Parameters:
appVersion
- app version used to identify the application.
-
requestTimeout
public AppConfiguration.Builder requestTimeout(long time, TimeUnit unit)
Sets the default timeout used by network requests against the MongoDB Realm application. Requests will terminate with a failure if they exceed this limit. The default value isAppConfiguration.DEFAULT_REQUEST_TIMEOUT
seconds.- Parameters:
time
- the timeout value for network requests.unit
- the unit of time used to define the timeout.
-
authorizationHeaderName
public AppConfiguration.Builder authorizationHeaderName(String headerName)
Sets the name of the HTTP header used to send authorization data in when making requests to MongoDB Realm. The MongoDB server or firewall must have been configured to expect a custom authorization header.The default authorization header is named
AppConfiguration.DEFAULT_AUTHORIZATION_HEADER_NAME
.- Parameters:
headerName
- name of the header.- Throws:
IllegalArgumentException
- if a null or empty header is provided.
-
addCustomRequestHeader
public AppConfiguration.Builder addCustomRequestHeader(String headerName, String headerValue)
Adds an extra HTTP header to append to every request to a Realm Object Server.- Parameters:
headerName
- the name of the header.headerValue
- the value of header.- Throws:
IllegalArgumentException
- if a non-emptyheaderName
is provided or a nullheaderValue
.
-
addCustomRequestHeaders
public AppConfiguration.Builder addCustomRequestHeaders(@Nullable Map<String,String> headers)
Adds extra HTTP headers to append to every request to a Realm Object Server.- Parameters:
headers
- map of (headerName, headerValue) pairs.- Throws:
IllegalArgumentException
- If any of the headers provided are illegal.
-
defaultSyncErrorHandler
public AppConfiguration.Builder defaultSyncErrorHandler(SyncSession.ErrorHandler errorHandler)
Sets the default error handler used by Synced Realms when reporting errors with their session.This default can be overridden by calling
SyncConfiguration.Builder.errorHandler(SyncSession.ErrorHandler)
when creating theSyncConfiguration
.- Parameters:
errorHandler
- the default error handler.
-
defaultClientResetHandler
@Deprecated public AppConfiguration.Builder defaultClientResetHandler(SyncSession.ClientResetHandler handler)
Deprecated.Sets the default Client Reset handler used by Synced Realms when they report a Client Reset. session.This default can be overridden by calling
SyncConfiguration.Builder.clientResetHandler(SyncSession.ClientResetHandler)
when creating theSyncConfiguration
.- Parameters:
handler
- the default Client Reset handler.
-
defaultSyncClientResetStrategy
public AppConfiguration.Builder defaultSyncClientResetStrategy(@Nonnull ManuallyRecoverUnsyncedChangesStrategy strategy)
Sets the default sync client reset strategy used by Synced Realms when they report a Client Reset. session.This default can be overridden by calling
SyncConfiguration.Builder.syncClientResetStrategy(ManuallyRecoverUnsyncedChangesStrategy)
orSyncConfiguration.Builder.syncClientResetStrategy(DiscardUnsyncedChangesStrategy)
when creating theSyncConfiguration
.- Parameters:
strategy
- the default sync client reset strategy.
-
defaultSyncClientResetStrategy
public AppConfiguration.Builder defaultSyncClientResetStrategy(@Nonnull DiscardUnsyncedChangesStrategy strategy)
Sets the default sync client reset strategy used by Synced Realms when they report a Client Reset. session.This default can be overridden by calling
SyncConfiguration.Builder.syncClientResetStrategy(ManuallyRecoverUnsyncedChangesStrategy)
orSyncConfiguration.Builder.syncClientResetStrategy(DiscardUnsyncedChangesStrategy)
when creating theSyncConfiguration
.- Parameters:
strategy
- the default sync client reset strategy.
-
syncRootDirectory
public AppConfiguration.Builder syncRootDirectory(File rootDir)
Configures the root folder containing all files and Realms used when synchronizing data between the device and MongoDB Realm.The default root dir is
Context.getFilesDir()/mongodb-realm
.- Parameters:
rootDir
- where to store sync related files.
-
codecRegistry
public AppConfiguration.Builder codecRegistry(CodecRegistry codecRegistry)
Set the default codec registry used to encode and decode BSON arguments and results when calling remote RealmFunctions
and accessing a remoteMongoDatabase
.Will default to
AppConfiguration.DEFAULT_BSON_CODEC_REGISTRY
if not specified.- Parameters:
codecRegistry
- The default codec registry for the App.- See Also:
AppConfiguration.DEFAULT_BSON_CODEC_REGISTRY
,AppConfiguration.getDefaultCodecRegistry()
-
httpLogObfuscator
public AppConfiguration.Builder httpLogObfuscator(@Nullable HttpLogObfuscator httpLogObfuscator)
Sets theHttpLogObfuscator
used to keep sensitive information in HTTP requests from being displayed in the logcat.If left unspecified, it will default to obfuscating HTTP login requests.
- Parameters:
httpLogObfuscator
- the default HTTP log obfuscator for the app.
-
build
public AppConfiguration build()
Creates the AppConfiguration.- Returns:
- the AppConfiguration that can be used to create a
App
.
-
-