| java.lang.Object | |
| ↳ | com.google.firebase.database.MutableData |
Instances of this class encapsulate the data and priority at a location.
It is used in transactions, and it is intended to be inspected and then updated
to the desired data at that location.
Note that changes made to a child MutableData instance will be visible to the
parent and vice versa.
| Public Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Used to obtain a MutableData instance that encapsulates the data and priority
at the given relative path.
| |||||||||||
Used to iterate over the immediate children at this location
| |||||||||||
Gets the current priority at this location.
| |||||||||||
Due to the way that Java implements generics, it takes an extra step to get back a properly-typed Collection.
| |||||||||||
getValue() returns the data contained in this instance as native types.
| |||||||||||
This method is used to marshall the data contained in this instance into a class of your choosing.
| |||||||||||
Sets the priority at this location
| |||||||||||
Set the data at this location to the given value.
| |||||||||||
|
[Expand]
Inherited Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
| |||||||||||
Used to obtain a MutableData instance that encapsulates the data and priority at the given relative path.
| path | A relative path |
|---|
Used to iterate over the immediate children at this location
for (MutableData child : parent.getChildren()) {
...
}
Gets the current priority at this location. The possible return types are:
Due to the way that Java implements generics, it takes an extra step to get back a properly-typed Collection.
So, in the case where you want a List of Message instances, you will need to do something like
the following:
GenericTypeIndicator<List<Message>> t = new GenericTypeIndicator<List<Message>>() {};
List<Message> messages = mutableData.getValue(t);
It is important to use a subclass of GenericTypeIndicator. See GenericTypeIndicator for more details| t | A subclass of GenericTypeIndicator indicating the type of generic collection to be returned. |
|---|
getValue() returns the data contained in this instance as native types. The possible types returned are:
Object
in the above list is given by the same list. These types correspond to the
types available in JSON.This method is used to marshall the data contained in this instance into a class of your choosing. The class must fit 2 simple constraints:
class Message {
private String author;
private String text;
private Message() {}
public Message(String author, String text) {
this.author = author;
this.text = text;
}
public String getAuthor() {
return author;
}
public String getText() {
return text;
}
}
// Later
Message m = mutableData.getValue(Message.class);
| valueType | The class into which this data in this instance should be marshalled |
|---|
| path | A relative path |
|---|
Sets the priority at this location
| priority | The desired priority |
|---|
Set the data at this location to the given value. The native types accepted by this method for the value correspond to the JSON types:
Map<String, MyPOJO>, as well as null values.
Note that this overrides the priority, which must be set separately.| value | The value to set at this location |
|---|
| DatabaseException |
|---|