Package io.realm.mongodb
Class App.Result<T>
- java.lang.Object
-
- io.realm.mongodb.App.Result<T>
-
- Type Parameters:
T
- Type returned if the request was a success.
- Enclosing class:
- App
public static class App.Result<T> extends Object
Result class representing the result of an async request from this app towards MongoDB Realm.- See Also:
App.Callback
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description T
get()
Returns the response in case the request was a success.AppException
getError()
Returns the error in case of a failed request.T
getOrDefault(T defaultValue)
Returns the response if the request was a success.T
getOrThrow()
If the request was successful the response is returned, otherwise the provided error is thrown.boolean
isSuccess()
Returns whether or not request was successfulstatic <T> App.Result<T>
success()
Creates a successful request result with no return value.static <T> App.Result<T>
withError(AppException exception)
Creates a failed request result.static <T> App.Result<T>
withResult(T result)
Creates a successful request result with a return value.
-
-
-
Method Detail
-
success
public static <T> App.Result<T> success()
Creates a successful request result with no return value.
-
withResult
public static <T> App.Result<T> withResult(T result)
Creates a successful request result with a return value.- Parameters:
result
- the result value.
-
withError
public static <T> App.Result<T> withError(AppException exception)
Creates a failed request result. The request failed for some reason, either because there was a network error or the Realm Object Server returned an error.- Parameters:
exception
- error that occurred.
-
isSuccess
public boolean isSuccess()
Returns whether or not request was successful- Returns:
true
if the request was a success,false
if not.
-
get
public T get()
Returns the response in case the request was a success.- Returns:
- the response value in case of a successful request.
-
getOrDefault
public T getOrDefault(T defaultValue)
Returns the response if the request was a success. If it failed, the default value is returned instead.- Returns:
- the response value in case of a successful request. If the request failed, the default value is returned instead.
-
getOrThrow
public T getOrThrow()
If the request was successful the response is returned, otherwise the provided error is thrown.- Returns:
- the response object in case the request was a success.
- Throws:
AppException
- provided error in case the request failed.
-
getError
public AppException getError()
Returns the error in case of a failed request.- Returns:
- the
AppException
in case of a failed request.
-
-