I'm storing objects on Firebase Realtime Database. An object looks like this:
import com.google.firebase.database.ServerValue;
public class Message {
private Object timestamp = ServerValue.TIMESTAMP;
private String source = "client";
private String req;
private String ack = null;
private int pos;
Message(){}; // needed for Firebase when converting DataSnapshot to Message object
Message(String req, int pos) {
this.req = req;
this.pos = pos;
}
public Object getTimestamp() {
return timestamp;
}
public String getSource() {
return source;
}
public String getReq() {
return req;
}
public String getAck() {
return ack;
}
public int getPos() {
return pos;
}
}
I haven't tried it yet, though the timestamp should correctly be populated when storing the object onto Firebase.
Now my question is: how can I add an expiration attribute? The expiration would be equal to the TIMESTAMP plus 30 seconds like so:
private Object expiration = ServerValue.TIMESTAMP + <30 seconds>;