public final class MesosferBeacon
extends java.lang.Object
MesosferBeacon
is a custom local representation of beacon data that can be saved and
retrieved from the Mesosfer cloud.
The basic workflow for creating new data is to construct a new MesosferBeacon
by accessing
createBeacon()
, use setter method to fill it with beacon 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 |
MesosferBeacon.Event
The enum Event of beacon.
|
static class |
MesosferBeacon.Module
The enum Module of beacon.
|
Constructor and Description |
---|
MesosferBeacon() |
Modifier and Type | Method and Description |
---|---|
static MesosferBeacon |
createBeacon()
Constructs a new
MesosferBeacon with no data in it. |
static MesosferBeacon |
createWithObjectId(java.lang.String objectId)
Creates a reference to an existing
MesosferBeacon . |
void |
deleteAsync(DeleteCallback callback)
Deletes this object on the server in a background thread.
|
void |
fetchAsync(GetCallback<MesosferBeacon> callback)
Fetches this object with the data from the server in a background thread.
|
java.util.Date |
getCreatedAt()
This reports time as the server sees it, so that if you create a
MesosferBeacon ,
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. |
MesosferObject |
getData()
Gets the
MesosferObject that already saved in MesosferBeacon . |
int |
getMajor()
Gets major number of beacon.
|
int |
getMinor()
Gets minor number of beacon.
|
java.lang.String |
getName()
Gets name of beacon.
|
java.lang.String |
getObjectId()
Accessor to the object id.
|
java.util.UUID |
getProximityUUID()
Gets proximity
UUID of beacon. |
static MesosferQuery<MesosferBeacon> |
getQuery()
Constructs a query for
MesosferBeacon . |
java.util.Date |
getUpdatedAt()
This reports time as the server sees it, so that if you make changes to a
MesosferBeacon ,
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
MesosferBeacon has been fetched. |
void |
saveAsync(SaveCallback callback)
Saves this object with the data from the server in a background thread.
|
MesosferBeacon |
setData(java.lang.String key,
java.lang.Object value)
Add a key-value pair to this object.
|
MesosferBeacon |
setMajor(int major)
Sets major number of beacon.
|
MesosferBeacon |
setMinor(int minor)
Sets minor number of beacon.
|
MesosferBeacon |
setName(java.lang.String name)
Sets name of beacon.
|
MesosferBeacon |
setProximityUUID(java.util.UUID uuid)
Sets proximity
UUID of beacon. |
org.json.JSONObject |
toJSON()
To put all keys and values of this
MesosferBeacon into a JSONObject . |
java.lang.String |
toString() |
public static MesosferBeacon createWithObjectId(java.lang.String objectId)
MesosferBeacon
. Calling isDataAvailable()
on this object will return false
until fetchAsync(GetCallback)
has been called.objectId
- The object id for the referenced beacon object.MesosferBeacon
without data.public static MesosferBeacon createBeacon()
MesosferBeacon
with no data in it. A MesosferBeacon
constructed in this way will not have an objectId and will not persist to the database until
saveAsync(SaveCallback)
is called.
Bucket names must be alphanumerical, and must start with a letter. It is recommended
to name classes in MesosferCaseLikeThis
.
MesosferBeacon
public java.lang.String getName()
String
of beacon's name.public java.util.UUID getProximityUUID()
UUID
of beacon. This value represents company identifier.UUID
of beacon.public int getMajor()
public int getMinor()
public MesosferObject getData()
MesosferObject
that already saved in MesosferBeacon
.MesosferObject
public boolean isDataAvailable()
MesosferBeacon
has been fetched.true
if the MesosferBeacon
is new or has been fetched.
false
otherwise.public java.lang.String getObjectId()
public java.util.Date getCreatedAt()
MesosferBeacon
,
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()
MesosferBeacon
,
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()
MesosferBeacon
into a JSONObject
.JSONObject
of all keys and valuespublic java.lang.String toString()
toString
in class java.lang.Object
public static MesosferQuery<MesosferBeacon> getQuery()
MesosferBeacon
.public MesosferBeacon setName(java.lang.String name)
name
- the name of beacon.public MesosferBeacon setProximityUUID(java.util.UUID uuid)
UUID
of beacon.uuid
- the proximity UUID
of beacon.public MesosferBeacon setMajor(int major)
major
- the major identifier of beacon.public MesosferBeacon setMinor(int minor)
minor
- the minor identifier of beacon.public MesosferBeacon setData(java.lang.String key, java.lang.Object value)
camelCaseLikeThis
.key
- Keys must be alphanumerical, and start with a letter.value
- Values may be numerical, String
, JSONObject
, JSONArray
,
JSONObject.NULL
, or Date
s. value may not be null
.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<MesosferBeacon> callback)
callback
- callback.done(object, e)
is called when the fetch completes.