public final class MesosferNotification
extends java.lang.Object
MesosferNotification
is a custom local representation of notification data that can be saved and retrieved from the Mesosfer cloud.
The basic workflow for creating new data is to construct a new MesosferNotification
by accessing
createNotification()
, use setter method to fill it with notification data, and then use
saveAsync(SaveCallback)
to persist to the cloud.
The basic workflow for accessing existing data is to use a MesosferQuery
to specify which
existing data to retrieve.Modifier and Type | Class and Description |
---|---|
static class |
MesosferNotification.Type
The enum Type.
|
Constructor and Description |
---|
MesosferNotification() |
Modifier and Type | Method and Description |
---|---|
static MesosferNotification |
createNotification()
Constructs a new
MesosferNotification with no data in it. |
static MesosferNotification |
createWithObjectId(java.lang.String objectId)
Creates a reference to an existing
MesosferNotification . |
void |
deleteAsync(DeleteCallback callback)
Deletes this object on the server in a background thread.
|
void |
fetchAsync(GetCallback<MesosferNotification> callback)
Fetches this object with the data from the server in a background thread.
|
MesosferBeacon |
getBeacon()
Gets the
MesosferBeacon that already saved in MesosferNotification . |
java.util.Date |
getCreatedAt()
This reports time as the server sees it, so that if you create a
MesosferNotification ,
then wait a while, and then call saveAsync(SaveCallback) , the creation time will be
the time of the first saveAsync(SaveCallback) call rather than the time the object
was created locally. |
java.lang.String |
getDescription()
Gets description of notification.
|
MesosferBeacon.Event |
getEvent()
Gets the
MesosferBeacon.Event that already saved in MesosferNotification . |
MesosferObject |
getMessage()
Gets the
MesosferObject that already saved in MesosferNotification . |
java.lang.String |
getObjectId()
Accessor to the object id.
|
static MesosferQuery<MesosferNotification> |
getQuery()
Constructs a query for
MesosferNotification . |
MesosferNotification.Type |
getType()
Gets the
MesosferNotification.Type that already saved in MesosferNotification . |
java.util.Date |
getUpdatedAt()
This reports time as the server sees it, so that if you make changes to a
MesosferNotification ,
then wait a while, and then call saveAsync(SaveCallback) , the updated time will be
the time of the saveAsync(SaveCallback) call rather than the time the object
was changed locally. |
boolean |
isDataAvailable()
Gets whether the
MesosferNotification has been fetched. |
boolean |
isEnabled()
Flag that indicate
MesosferNotification is enabled or disabled. |
MesosferNotification |
isEnabled(boolean enabled)
Sets enabled or disabled for notification.
|
void |
saveAsync(SaveCallback callback)
Saves this object with the data from the server in a background thread.
|
MesosferNotification |
setBeacon(MesosferBeacon beacon)
Sets notification beacon.
|
MesosferNotification |
setDescription(java.lang.String description)
Sets notification description.
|
MesosferNotification |
setEvent(MesosferBeacon.Event event)
Sets event for notification.
|
MesosferNotification |
setMessage(MesosferObject message)
Sets notification message.
|
MesosferNotification |
setType(MesosferNotification.Type type)
Sets type for notification.
|
org.json.JSONObject |
toJSON()
To put all keys and values of this
MesosferNotification into a JSONObject . |
java.lang.String |
toString() |
public static MesosferNotification createWithObjectId(java.lang.String objectId)
MesosferNotification
. Calling isDataAvailable()
on this object will return false
until fetchAsync(GetCallback)
has been called.objectId
- The object id for the referenced notification object.MesosferNotification
without data.public static MesosferNotification createNotification()
MesosferNotification
with no data in it. A MesosferNotification
constructed in this way will not have an objectId and will not persist to the database until
saveAsync(SaveCallback)
is called.MesosferNotification
public java.lang.String getDescription()
String
name of notification.public MesosferObject getMessage()
MesosferObject
that already saved in MesosferNotification
.MesosferObject
public MesosferBeacon getBeacon()
MesosferBeacon
that already saved in MesosferNotification
.MesosferBeacon
public boolean isEnabled()
MesosferNotification
is enabled or disabled.public MesosferBeacon.Event getEvent()
MesosferBeacon.Event
that already saved in MesosferNotification
.MesosferBeacon.Event
public MesosferNotification.Type getType()
MesosferNotification.Type
that already saved in MesosferNotification
.MesosferNotification.Type
public boolean isDataAvailable()
MesosferNotification
has been fetched.true
if the MesosferNotification
is new or has been fetched.
false
otherwise.public java.lang.String getObjectId()
public java.util.Date getCreatedAt()
MesosferNotification
,
then wait a while, and then call saveAsync(SaveCallback)
, the creation time will be
the time of the first saveAsync(SaveCallback)
call rather than the time the object
was created locally.public java.util.Date getUpdatedAt()
MesosferNotification
,
then wait a while, and then call saveAsync(SaveCallback)
, the updated time will be
the time of the saveAsync(SaveCallback)
call rather than the time the object
was changed locally.public org.json.JSONObject toJSON()
MesosferNotification
into a JSONObject
.JSONObject
of all keys and valuespublic java.lang.String toString()
toString
in class java.lang.Object
public static MesosferQuery<MesosferNotification> getQuery()
MesosferNotification
.public MesosferNotification setDescription(java.lang.String description)
description
- the description of notification.public MesosferNotification setMessage(MesosferObject message)
message
- the messagepublic MesosferNotification setBeacon(MesosferBeacon beacon)
beacon
- the MesosferBeacon
public MesosferNotification isEnabled(boolean enabled)
enabled
- public MesosferNotification setEvent(MesosferBeacon.Event event)
event
- the MesosferBeacon.Event
public MesosferNotification setType(MesosferNotification.Type type)
type
- the MesosferNotification.Type
public void deleteAsync(DeleteCallback callback)
callback
- callback.done(e)
is called when the save completes.public void saveAsync(SaveCallback callback)
callback
- callback.done(e)
is called when the save completes.public void fetchAsync(GetCallback<MesosferNotification> callback)
callback
- callback.done(object, e)
is called when the fetch completes.