Package io.realm.mongodb.functions
Class Functions
- java.lang.Object
-
- io.realm.mongodb.functions.Functions
-
public abstract class Functions extends Object
A Functions manager to call remote Realm functions for the associated Realm App.Arguments and results are encoded/decoded with the Functions' codec registry either inherited from the
AppConfiguration.getDefaultCodecRegistry()
or set explicitly when creating the Functions-instance throughUser.getFunctions(CodecRegistry)
or through the individual calls tocallFunction(String, List, Class, CodecRegistry)
.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <ResultT> ResultT
callFunction(String name, List<?> args, Class<ResultT> resultClass)
Call a MongoDB Realm function synchronously with default codec registry encoding/decoding arguments/results.<ResultT> ResultT
callFunction(String name, List<?> args, Class<ResultT> resultClass, CodecRegistry codecRegistry)
Call a MongoDB Realm function synchronously with custom codec registry encoding/decoding arguments/results.<ResultT> ResultT
callFunction(String name, List<?> args, Decoder<ResultT> resultDecoder)
Call a MongoDB Realm function synchronously with custom result decoder.<T> RealmAsyncTask
callFunctionAsync(String name, List<?> args, Class<T> resultClass, App.Callback<T> callback)
Call a MongoDB Realm function asynchronously with custom codec registry for encoding/decoding arguments/results.<T> RealmAsyncTask
callFunctionAsync(String name, List<?> args, Class<T> resultClass, CodecRegistry codecRegistry, App.Callback<T> callback)
Call a MongoDB Realm function asynchronously with custom codec registry for encoding/decoding arguments/results.<T> RealmAsyncTask
callFunctionAsync(String name, List<?> args, Decoder<T> resultDecoder, App.Callback<T> callback)
Call a MongoDB Realm function asynchronously with custom result decoder.App
getApp()
Returns theApp
that this instance in associated with.CodecRegistry
getDefaultCodecRegistry()
Returns the default codec registry used for encoding arguments and decoding results for this Realm functions instance.User
getUser()
Returns theUser
that this instance in associated with.
-
-
-
Method Detail
-
callFunction
public <ResultT> ResultT callFunction(String name, List<?> args, Class<ResultT> resultClass, CodecRegistry codecRegistry)
Call a MongoDB Realm function synchronously with custom codec registry encoding/decoding arguments/results.- Type Parameters:
ResultT
- The type that the response will be decoded as using thecodecRegistry
.- Parameters:
name
- Name of the Realm function to call.args
- Arguments to the Realm function.resultClass
- The type that the functions result should be converted to.codecRegistry
- Codec registry to use for argument encoding and result decoding.- Returns:
- Result of the Realm function.
- Throws:
AppException
- if the request failed in some way.- See Also:
callFunctionAsync(String, List, Class, CodecRegistry, App.Callback)
,AppConfiguration.getDefaultCodecRegistry()
-
callFunction
public <ResultT> ResultT callFunction(String name, List<?> args, Class<ResultT> resultClass)
Call a MongoDB Realm function synchronously with default codec registry encoding/decoding arguments/results.- Type Parameters:
ResultT
- The type that the response will be decoded as using the default codec registry.- Parameters:
name
- Name of the Realm function to call.args
- Arguments to the Realm function.resultClass
- The type that the functions result should be converted to.- Returns:
- Result of the Realm function.
- Throws:
AppException
- if the request failed in some way.- See Also:
callFunction(String, List, Class, CodecRegistry)
,AppConfiguration.getDefaultCodecRegistry()
-
callFunction
public <ResultT> ResultT callFunction(String name, List<?> args, Decoder<ResultT> resultDecoder)
Call a MongoDB Realm function synchronously with custom result decoder.The arguments will be encoded with the default codec registry encoding.
- Type Parameters:
ResultT
- The type that the response will be decoded as using theresultDecoder
- Parameters:
name
- Name of the Realm function to call.args
- Arguments to the Realm function.resultDecoder
- The decoder used to decode the result.- Returns:
- Result of the Realm function.
- Throws:
AppException
- if the request failed in some way.- See Also:
callFunction(String, List, Class, CodecRegistry)
,AppConfiguration.getDefaultCodecRegistry()
-
callFunctionAsync
public <T> RealmAsyncTask callFunctionAsync(String name, List<?> args, Class<T> resultClass, CodecRegistry codecRegistry, App.Callback<T> callback)
Call a MongoDB Realm function asynchronously with custom codec registry for encoding/decoding arguments/results.This is the asynchronous equivalent of
callFunction(String, List, Class, CodecRegistry)
.- Type Parameters:
T
- The type that the response will be decoded as using the default codec registry.- Parameters:
name
- Name of the Realm function to call.args
- Arguments to the Realm function.resultClass
- The type that the functions result should be converted to.codecRegistry
- Codec registry to use for argument encoding and result decoding.callback
- The callback that will receive the result or any errors from the request.- Returns:
- The task representing the ongoing operation.
- Throws:
IllegalStateException
- if not called on a looper thread.- See Also:
callFunction(String, List, Class, CodecRegistry)
,callFunctionAsync(String, List, Class, CodecRegistry, App.Callback)
,AppConfiguration.getDefaultCodecRegistry()
-
callFunctionAsync
public <T> RealmAsyncTask callFunctionAsync(String name, List<?> args, Class<T> resultClass, App.Callback<T> callback)
Call a MongoDB Realm function asynchronously with custom codec registry for encoding/decoding arguments/results.This is the asynchronous equivalent of
callFunction(String, List, Class)
.- Type Parameters:
T
- The type that the response will be decoded as using the default codec registry.- Parameters:
name
- Name of the Realm function to call.args
- Arguments to the Realm function.resultClass
- The type that the functions result should be converted to.callback
- The callback that will receive the result or any errors from the request.- Returns:
- The task representing the ongoing operation.
- Throws:
IllegalStateException
- if not called on a looper thread.- See Also:
callFunction(String, List, Class)
,callFunctionAsync(String, List, Class, CodecRegistry, App.Callback)
,AppConfiguration.getDefaultCodecRegistry()
-
callFunctionAsync
public <T> RealmAsyncTask callFunctionAsync(String name, List<?> args, Decoder<T> resultDecoder, App.Callback<T> callback)
Call a MongoDB Realm function asynchronously with custom result decoder.This is the asynchronous equivalent of
callFunction(String, List, Decoder)
.- Type Parameters:
T
- The type that the response will be decoded as using theresultDecoder
- Parameters:
name
- Name of the Realm function to call.args
- Arguments to the Realm function.resultDecoder
- The decoder used to decode the result.callback
- The callback that will receive the result or any errors from the request.- Returns:
- The task representing the ongoing operation.
- Throws:
IllegalStateException
- if not called on a looper thread.- See Also:
callFunction(String, List, Class)
,callFunctionAsync(String, List, Class, CodecRegistry, App.Callback)
,AppConfiguration.getDefaultCodecRegistry()
-
getDefaultCodecRegistry
public CodecRegistry getDefaultCodecRegistry()
Returns the default codec registry used for encoding arguments and decoding results for this Realm functions instance.- Returns:
- The default codec registry.
-
getApp
public App getApp()
Returns theApp
that this instance in associated with.- Returns:
- The
App
that this instance in associated with.
-
-