public final class Monarchy
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static class |
Monarchy.Builder
Builder class used to build a Monarchy instance.
|
static class |
Monarchy.ManagedChangeSet<T extends RealmModel>
A class that contains the RealmResults and the OrderedCollectionChangeSet.
|
static interface |
Monarchy.Mapper<R,T>
A mapper interface that can be used in
findAllMappedWithChanges(Query, Mapper) to map out instances on the background looper thread. |
static interface |
Monarchy.Query<T extends RealmModel>
An interface used to define Realm queries, therefore bypassing the thread-local aspect of RealmQuery.
|
static interface |
Monarchy.RealmBlock
Interface to define what to do with the Realm instance.
|
static class |
Monarchy.RealmDataSourceFactory<T extends RealmModel>
A DataSource.Factory that handles integration of RealmResults through Paging.
|
| Modifier and Type | Method and Description |
|---|---|
void |
closeManually()
If the Monarchy thread was opened manually, then this method can be used to decrement the forced reference count increment.
|
<T extends RealmModel> |
createDataSourceFactory(Monarchy.Query<T> query)
Creates a DataSource.Factory of (Integer, T) that can be used for creating a paged result set.
|
void |
doWithRealm(Monarchy.RealmBlock realmBlock)
Allows to manually use Realm instance and will automatically close it when done.
|
<T extends RealmModel> |
fetchAllCopiedSync(Monarchy.Query<T> query)
Provides ability to synchronously fetch a copied RealmResults.
|
<T extends RealmModel> |
fetchAllManagedSync(Realm realm,
Monarchy.Query<T> query)
Provides ability to synchronously obtain a managed RealmResults as a List, in a safe way.
|
<T extends RealmModel,U> |
fetchAllMappedSync(Monarchy.Query<T> query,
Monarchy.Mapper<U,T> mapper)
Provides ability to synchronously fetch a mapped RealmResults.
|
<T extends RealmModel> |
findAllCopiedWithChanges(Monarchy.Query<T> query)
Returns a LiveData that evaluates the new results on a background looper thread.
|
<T extends RealmModel> |
findAllFrozenWithChanges(Monarchy.Query<T> query)
Returns a LiveData that evaluates the new results on a background looper thread.
|
<T extends RealmModel> |
findAllManagedWithChanges(Monarchy.Query<T> query)
Returns a LiveData that evaluates the new results on the UI thread, using Realm's Async Query API.
|
<T extends RealmModel> |
findAllManagedWithChangesSync(Monarchy.Query<T> query)
Returns a LiveData that evaluates the new results on the UI thread, using Realm's Sync Query API.
|
<T extends RealmModel,U> |
findAllMappedWithChanges(Monarchy.Query<T> query,
Monarchy.Mapper<U,T> mapper)
Returns a LiveData that evaluates the new results on a background looper thread.
|
<R,T extends RealmModel> |
findAllPagedWithChanges(<any> dataSourceFactory,
<any> livePagedListBuilder)
Returns a LiveData that evaluates the new results on a background looper thread.
|
static RealmConfiguration |
getDefaultConfiguration()
Returns the default configuration.
|
RealmConfiguration |
getRealmConfiguration() |
static void |
init(android.content.Context context)
Initializes Realm as usual, except sets a default configuration to detect if a custom default is properly set.
|
boolean |
isMonarchyThreadOpen()
Returns if the Monarchy thread is open.
|
void |
openManually()
Forcefully opens the Monarchy thread, keeping it alive until
closeManually() is called. |
void |
postToMonarchyThread(Monarchy.RealmBlock realmBlock)
Posts the RealmBlock to the Monarchy thread, and executes it there.
|
void |
runTransactionSync(Realm.Transaction transaction) |
static void |
setDefaultConfiguration(RealmConfiguration realmConfiguration)
Calls Realm.setDefaultConfiguration(config).
|
void |
writeAsync(Realm.Transaction transaction)
Writes asynchronously on a single-threaded execution pool.
|
public static void init(android.content.Context context)
context - app contextpublic static void setDefaultConfiguration(RealmConfiguration realmConfiguration)
realmConfiguration - realm configurationpublic static RealmConfiguration getDefaultConfiguration()
java.lang.IllegalStateException - if the invalid default configuration is still set.public final RealmConfiguration getRealmConfiguration()
public final void runTransactionSync(Realm.Transaction transaction)
public final void doWithRealm(Monarchy.RealmBlock realmBlock)
realmBlock - the Realm execution block in which Realm should remain openpublic final void writeAsync(Realm.Transaction transaction)
transaction - the Realm transactionpublic <T extends RealmModel> java.util.List<T> fetchAllManagedSync(Realm realm,
Monarchy.Query<T> query)
doWithRealm(RealmBlock) (or runTransactionSync(Realm.Transaction) method).T - RealmObject typerealm - Realmquery - Querypublic <T extends RealmModel> java.util.List<T> fetchAllCopiedSync(Monarchy.Query<T> query)
T - RealmObject typequery - Querypublic <T extends RealmModel,U> java.util.List<U> fetchAllMappedSync(Monarchy.Query<T> query, Monarchy.Mapper<U,T> mapper)
T - RealmObject typeU - the mapped typequery - Querypublic <T extends RealmModel> <any> findAllCopiedWithChanges(Monarchy.Query<T> query)
T - the RealmModel typequery - the querypublic <T extends RealmModel> <any> findAllFrozenWithChanges(Monarchy.Query<T> query)
T - the RealmModel typequery - the querypublic <T extends RealmModel,U> <any> findAllMappedWithChanges(Monarchy.Query<T> query, Monarchy.Mapper<U,T> mapper)
Monarchy.Mapper.T - the RealmModel typeU - the mapped typequery - the querypublic <T extends RealmModel> <any> findAllManagedWithChanges(Monarchy.Query<T> query)
T - the RealmModel typequery - the querypublic <T extends RealmModel> <any> findAllManagedWithChangesSync(Monarchy.Query<T> query)
T - the RealmModel typequery - the querypublic void openManually()
closeManually() is called.public void closeManually()
public boolean isMonarchyThreadOpen()
public void postToMonarchyThread(Monarchy.RealmBlock realmBlock)
realmBlock - the Realm blockjava.lang.IllegalStateException - if the Monarchy thread is not openpublic <T extends RealmModel> Monarchy.RealmDataSourceFactory<T> createDataSourceFactory(Monarchy.Query<T> query)
query - the querypublic <R,T extends RealmModel> <any> findAllPagedWithChanges(<any> dataSourceFactory,
<any> livePagedListBuilder)