public interface DatabaseDistribution
Before you do some operations on database you should chose on which parts of data you want to operate.
To do that you need to call inReference(String) before each of following methods:
setValue(Object)
setValue(Object, CompleteCallback)
updateChildren(Map)
updateChildren(Map, CompleteCallback)
onDataChange(Class, DataChangeListener)
readValue(Class, DataCallback)
push()
transaction(Class, TransactionCallback, CompleteCallback)
If you do not do this RuntimeException will be thrown.
| Modifier and Type | Method and Description |
|---|---|
DatabaseDistribution |
inReference(java.lang.String databasePath)
Sets database path you want to deal with in next action.
|
void |
keepSynced(boolean synced)
Keeps data fresh.
|
void |
onConnect(ConnectedListener connectedListener)
Listens for database connection events.
|
<T,R extends T> |
onDataChange(java.lang.Class<T> dataType,
DataChangeListener<R> listener)
Handles value changes for path given by
inReference(String) and gives response by DataChangeListener. |
DatabaseDistribution |
push()
Creates new object inside database and return
this instance with reference to it set by DatabaseDistribution#inReference()
Remember to set database reference earlier by calling the inReference(String) method. |
<T,R extends T> |
readValue(java.lang.Class<T> dataType,
DataCallback<R> callback)
Reads value from path given by
inReference(String) and gives response by DataCallback. |
void |
removeValue()
Removes value in path given by
inReference(String). |
void |
removeValue(CompleteCallback completeCallback)
Removes value for path given by
inReference(String) and gives response by DataChangeListener. |
void |
setPersistenceEnabled(boolean enabled)
Keeps your data for offline usage.
|
void |
setValue(java.lang.Object value)
Sets value for path given by
inReference(String). |
void |
setValue(java.lang.Object value,
CompleteCallback completeCallback)
Sets value for path given by
inReference(String) and gives response by CompleteCallback. |
<T,R extends T> |
transaction(java.lang.Class<T> dataType,
TransactionCallback<R> transactionCallback,
CompleteCallback completeCallback)
Provides transaction for value describe by path given by
inReference(String) and gives response by CompleteCallback
Value that you want to change will be get in TransactionCallback.run(Object) - there you should
modifying data and returns a new one. |
void |
updateChildren(java.util.Map<java.lang.String,java.lang.Object> data)
Updates children's for path given by
inReference(String). |
void |
updateChildren(java.util.Map<java.lang.String,java.lang.Object> data,
CompleteCallback completeCallback)
Updates children's for path given by
inReference(String) and gives response by CompleteCallback. |
void onConnect(ConnectedListener connectedListener)
Catch moment when application is going to to be connected or disconnected to the database.
connectedListener - Listener that handles moments when connection status into database was changeDatabaseDistribution inReference(java.lang.String databasePath)
databasePath - Reference inside your database for ex. "/users"void setValue(java.lang.Object value)
inReference(String).value - Any value which you want to store. Given object will be transformed to Firebase-like data type.java.lang.RuntimeException - if inReference(String) was not call before.void setValue(java.lang.Object value,
CompleteCallback completeCallback)
inReference(String) and gives response by CompleteCallback.value - Any value which you want to store. Given object will be transformed to Firebase-like data type.completeCallback - Callback that handles responsejava.lang.RuntimeException - if inReference(String) was not call before.CompleteCallback<T,R extends T> void readValue(java.lang.Class<T> dataType,
DataCallback<R> callback)
inReference(String) and gives response by DataCallback.T - Type of data you want to retrieve, associated with dataType for ex. List.classR - More specific type of data you want to retrieve associated with callback - needed because of nested generic types for ex. List<User>dataType - Class you want to retrievecallback - Callback that handles responsejava.lang.RuntimeException - if inReference(String) was not call before.DataCallback<T,R extends T> void onDataChange(java.lang.Class<T> dataType,
DataChangeListener<R> listener)
inReference(String) and gives response by DataChangeListener.
Remember to set database reference earlier by calling the inReference(String) method.
T - Type of data you want to retrieve, associated with dataType for ex. List.classR - More specific type of data you want to retrieve associated with listener - needed because of nested generic types for ex. List<User>dataType - Class you want to retrievelistener - Listener, may by null - if null all listeners for specified database reference will be removed.java.lang.RuntimeException - if inReference(String) was not call before.DataChangeListenerDatabaseDistribution push()
this instance with reference to it set by DatabaseDistribution#inReference()
Remember to set database reference earlier by calling the inReference(String) method.
java.lang.RuntimeException - if inReference(String) was not call before.void removeValue()
inReference(String).
Remember to set database reference earlier by calling the inReference(String) method.
java.lang.RuntimeException - if inReference(String) was not call before.void removeValue(CompleteCallback completeCallback)
inReference(String) and gives response by DataChangeListener.
Remember to set database reference earlier by calling the inReference(String) method.
completeCallback - Complete callbackjava.lang.RuntimeException - if inReference(String) was not call before.CompleteCallbackvoid updateChildren(java.util.Map<java.lang.String,java.lang.Object> data)
inReference(String).
Remember to set database reference earlier by calling the inReference(String) method.
data - New datajava.lang.RuntimeException - if inReference(String) was not call before.void updateChildren(java.util.Map<java.lang.String,java.lang.Object> data,
CompleteCallback completeCallback)
inReference(String) and gives response by CompleteCallback.
Remember to set database reference earlier by calling the inReference(String) method.
data - New datacompleteCallback - Callback when donejava.lang.RuntimeException - if inReference(String) was not call before.<T,R extends T> void transaction(java.lang.Class<T> dataType,
TransactionCallback<R> transactionCallback,
CompleteCallback completeCallback)
inReference(String) and gives response by CompleteCallback
Value that you want to change will be get in TransactionCallback.run(Object) - there you should
modifying data and returns a new one.
Remember to set database reference earlier by calling the inReference(String) method.
dataType - Type of data you want to get.transactionCallback - Callback called when transaction is complete.completeCallback - Can be nulljava.lang.RuntimeException - if inReference(String) was not call before call this method.CompleteCallback,
TransactionCallbackvoid setPersistenceEnabled(boolean enabled)
enabled - evoid keepSynced(boolean synced)
You can read more here and here
Remember to set database reference earlier by calling the inReference(String) method.
synced - If true sync for specified database path will be enabledjava.lang.RuntimeException - if inReference(String) was not call before call this method.