Package cn.leancloud
Class LCObject
java.lang.Object
cn.leancloud.LCObject
- Direct Known Subclasses:
LCBlockRelation,LCFile,LCFriendship,LCFriendshipRequest,LCInstallation,LCRole,LCStatus,LCUser
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected LCACLprotected Stringprotected Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringprotected static final LCLoggerprotected Stringprotected ConcurrentMap<String, cn.leancloud.ops.ObjectFieldOperation> protected ConcurrentMap<String, Object> protected booleanprotected static final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidabort all modify operations.voidAdd attribute.voidaddAll(String key, Collection<?> values) Add collection attribute.voidaddAllUnique(String key, Collection<?> values) Add unique collection attribute.protected voidaddNewOperation(cn.leancloud.ops.ObjectFieldOperation op) voidAdd unique attribute.voidModify integer attribute.voidModify integer attribute.voidModify integer attribute.protected static <T extends LCObject>
TbooleancontainsKey(String key) Contain specified key.static <T extends LCObject>
TcreateWithoutData(Class<T> clazz, String objectId) Create a new instance with particular class and objectId.static LCObjectcreateWithoutData(String className, String objectId) Create a new instance with particular classname and objectId.voidDecrement one attribute.voidDecrement one attribute.voiddelete()Delete current object in blocking mode.voidDelete current object in blocking mode.static voiddeleteAll(LCUser asAuthenticatedUser, Collection<? extends LCObject> objects) Delete all objects in blocking mode.static voiddeleteAll(Collection<? extends LCObject> objects) Delete all objects in blocking mode.static io.reactivex.Observable<LCNull> deleteAllInBackground(LCUser asAuthenticatedUser, Collection<? extends LCObject> objects) Delete all objects in async mode.static io.reactivex.Observable<LCNull> deleteAllInBackground(Collection<? extends LCObject> objects) Delete all objects in async mode.voidDelete current object eventually.voiddeleteEventually(LCUser asAuthenticatedUser) Delete current object eventually.io.reactivex.Observable<LCNull> Delete current object in async mode.io.reactivex.Observable<LCNull> deleteInBackground(LCUser asAuthenticatedUser) Delete current object in async mode.voiddisable afterXXX Hooksvoiddisable beforeXXX Hooksbooleanfetch()Fetch current object in blocking mode.Fetch current object in blocking mode.Fetch current object in blocking mode.Fetch current object in blocking mode.io.reactivex.Observable<LCObject> Fetch current object if needed in async mode.io.reactivex.Observable<LCObject> fetchIfNeededInBackground(LCUser asAuthenticatedUser, String includeKeys) Fetch current object if needed in async mode.io.reactivex.Observable<LCObject> fetchIfNeededInBackground(String includeKeys) Fetch current object if needed in async mode.io.reactivex.Observable<LCObject> Fetch current object in async mode.io.reactivex.Observable<LCObject> fetchInBackground(LCUser asAuthenticatedUser, String includeKeys) Fetch current object in async mode.io.reactivex.Observable<LCObject> fetchInBackground(String includeKeys) Fetch current object in async mode.protected LCACLprotected JSONObjectsave/update with server.Get value of specified key.getACL()get ACLbooleangetBoolean(String key) Get boolean value of specified key.byte[]Get bytes value of specified key.Get class name.Get createdAt date.Get createdAt string.Get Date value of specified key.doubleGet double value of specified key.intGet int value of specified key.getJSONArray(String key) Get jsonarray value of specified key.getJSONObject(String key) Get jsonobject value of specified key.Get AVFile value of specified key.getLCGeoPoint(String key) Get AVGeoPoint value of specified key.<T extends LCObject>
TgetLCObject(String key) Get AVObject value of specified key.Get list value of specified key.longGet long value of specified key.Get numeric value of specified key.Get objectId.Get query for class.<T extends LCObject>
LCRelation<T> getRelation(String key) Get AVRelation value of specified key.Get request method.Get request endpoint.Get server data.Get string value of specified key.Get updatedAt date.Get updatedAt string.getUuid()Get UUID.booleanContain specified key.booleanhasCircleReference(Map<LCObject, Boolean> markMap) judge operations' value include circle reference or not.inthashCode()voidignoreHook(LCObject.Hook hook) ignore specified HookvoidIncrement one attribute.voidIncrement one attribute.Get internal class name.protected ObjectinternalGet(String key) protected Stringprotected voidinternalPut(String key, Object value) booleanFlag to indicate data is available or not.booleanFlag to fetchWhenSave.protected voidprotected voidprotected voidstatic LCObjectparseLCObject(String objectString) Create AVObject instance from json string which generated by AVObject.toString or AVObject.toJSONString.voidSet attribute.voidrefresh()Refresh current object in blocking mode.voidRefresh current object in blocking mode.voidRefresh current object in blocking mode.io.reactivex.Observable<LCObject> Refresh current object in async mode.io.reactivex.Observable<LCObject> refreshInBackground(LCUser asAuthenticatedUser) Refresh current object in async mode.io.reactivex.Observable<LCObject> refreshInBackground(LCUser asAuthenticatedUser, String includeKeys) Refresh current object in async mode.io.reactivex.Observable<LCObject> refreshInBackground(String includeKeys) Refresh current object in async mode.static <T extends LCObject>
voidregisterSubclass(Class<T> clazz) Register subclass to AVOSCloud SDK.It must be invocated before AVOSCloud.initialize.voidRemove attribute.voidremoveAll(String key, Collection<?> values) Remove all collection.protected voidprotected voidresetAll()protected voidresetByRawData(LCObject LCObject) voidresetServerData(Map<String, Object> data) Reset server data with new data.voidsave()Save in blocking mode.voidSave in blocking mode.static voidsaveAll(LCUser asAuthenticatedUser, Collection<? extends LCObject> objects) Save All objects in blocking mode.static voidsaveAll(Collection<? extends LCObject> objects) Save All objects in blocking mode.static io.reactivex.Observable<JSONArray> saveAllInBackground(LCUser asAuthenticatedUser, Collection<? extends LCObject> objects) Save all objects in async mode.static io.reactivex.Observable<JSONArray> saveAllInBackground(Collection<? extends LCObject> objects) Save all objects in async mode.voidSave eventually.voidsaveEventually(LCUser asAuthenticatedUser) Save eventually.io.reactivex.Observable<? extends LCObject> Save object in background.io.reactivex.Observable<? extends LCObject> saveInBackground(LCSaveOption option) Save object in background.io.reactivex.Observable<? extends LCObject> saveInBackground(LCUser asAuthenticatedUser) Save object in background.io.reactivex.Observable<? extends LCObject> saveInBackground(LCUser asAuthenticatedUser, LCSaveOption option) Save object in background.voidSet ACLvoidsetClassName(String name) Set class name.voidsetFetchWhenSave(boolean fetchWhenSave) Set fetchWhenSave flag.voidsetObjectId(String objectId) Set objectId.Generate a new json object with server data.Generate a json string.toString()protected voidvalidFieldName(String key) protected static booleanverifyInternalId(String internalId)
-
Field Details
-
KEY_CREATED_AT
- See Also:
-
KEY_UPDATED_AT
- See Also:
-
KEY_OBJECT_ID
- See Also:
-
KEY_ACL
- See Also:
-
KEY_CLASSNAME
- See Also:
-
KEY_IGNORE_HOOKS
- See Also:
-
logger
-
UUID_LEN
protected static final int UUID_LEN -
className
-
endpointClassName
-
objectId
-
serverData
-
operations
-
acl
-
totallyOverwrite
protected volatile boolean totallyOverwrite
-
-
Constructor Details
-
LCObject
public LCObject()Default constructor. -
LCObject
Constructor with class name.- Parameters:
className- class name.
-
LCObject
Copy constructor.- Parameters:
other- other instance.
-
-
Method Details
-
getClassName
Get class name.- Returns:
- class name.
-
internalClassName
Get internal class name.- Returns:
- internal class name.
-
setClassName
Set class name.- Parameters:
name- class name.
-
getCreatedAt
Get createdAt date.- Returns:
- createdAt date.
-
getCreatedAtString
Get createdAt string.- Returns:
- createdAt string.
-
getUpdatedAt
Get updatedAt date.- Returns:
- updatedAt date.
-
getUpdatedAtString
Get updatedAt string.- Returns:
- updatedAt string.
-
getObjectId
Get objectId.- Returns:
- objectId.
-
setObjectId
Set objectId.- Parameters:
objectId- object id.
-
isFetchWhenSave
public boolean isFetchWhenSave()Flag to fetchWhenSave.- Returns:
- flag for fetchWhenSave.
-
setFetchWhenSave
public void setFetchWhenSave(boolean fetchWhenSave) Set fetchWhenSave flag.- Parameters:
fetchWhenSave- flag.
-
getUuid
Get UUID.- Returns:
- UUID. Caution: public this method just for compatibility.
-
verifyInternalId
-
internalId
-
containsKey
Contain specified key.- Parameters:
key- key- Returns:
- flag to indicate current object contains the specified key or not.
-
has
Contain specified key.- Parameters:
key- key- Returns:
- flag to indicate current object contains the specified key or not.
-
get
Get value of specified key.- Parameters:
key- specified key.- Returns:
- the value associated with specified key.
-
internalGet
-
getBoolean
Get boolean value of specified key.- Parameters:
key- specified key.- Returns:
- the boolean value associated with specified key.
-
getBytes
Get bytes value of specified key.- Parameters:
key- specified key.- Returns:
- the bytes value associated with specified key.
-
getDate
Get Date value of specified key.- Parameters:
key- specified key.- Returns:
- the Date value associated with specified key.
-
getString
Get string value of specified key.- Parameters:
key- specified key.- Returns:
- the string value associated with specified key.
-
getInt
Get int value of specified key.- Parameters:
key- specified key.- Returns:
- the int value associated with specified key.
-
getLong
Get long value of specified key.- Parameters:
key- specified key.- Returns:
- the long value associated with specified key.
-
getDouble
Get double value of specified key.- Parameters:
key- specified key.- Returns:
- the double value associated with specified key.
-
getNumber
Get numeric value of specified key.- Parameters:
key- specified key.- Returns:
- the numeric value associated with specified key.
-
getList
Get list value of specified key.- Parameters:
key- specified key.- Returns:
- the list value associated with specified key.
-
getJSONArray
Get jsonarray value of specified key.- Parameters:
key- specified key.- Returns:
- the jsonarray value associated with specified key.
-
getJSONObject
Get jsonobject value of specified key.- Parameters:
key- specified key.- Returns:
- the jsonobject value associated with specified key.
-
getLCGeoPoint
Get AVGeoPoint value of specified key.- Parameters:
key- specified key.- Returns:
- the AVGeoPoint value associated with specified key.
-
getLCFile
Get AVFile value of specified key.- Parameters:
key- specified key.- Returns:
- the AVFile value associated with specified key.
-
getLCObject
Get AVObject value of specified key.- Type Parameters:
T- template type- Parameters:
key- specified key.- Returns:
- the AVObject value associated with specified key.
-
getRelation
Get AVRelation value of specified key.- Type Parameters:
T- template type- Parameters:
key- specified key.- Returns:
- the AVRelation value associated with specified key.
-
getServerData
Get server data.- Returns:
- map of server data.
-
validFieldName
-
isDataAvailable
public boolean isDataAvailable()Flag to indicate data is available or not.- Returns:
- available flag.
-
add
Add attribute.- Parameters:
key- target key.value- value object.
-
addAll
Add collection attribute.- Parameters:
key- target key.values- values collection.
-
addUnique
Add unique attribute.- Parameters:
key- target key.value- value object.
-
addAllUnique
Add unique collection attribute.- Parameters:
key- target key.values- value collection.
-
put
Set attribute.- Parameters:
key- target key.value- value object.
-
internalPut
-
remove
Remove attribute.- Parameters:
key- target key.
-
removeAll
Remove all collection.- Parameters:
key- target keys.values- value collection.
-
increment
Increment one attribute.- Parameters:
key- target key.
-
increment
Increment one attribute.- Parameters:
key- target key.value- value object.
-
decrement
Decrement one attribute.- Parameters:
key- target key.
-
decrement
Decrement one attribute.- Parameters:
key- target key.value- value object.
-
bitAnd
Modify integer attribute.- Parameters:
key- target key.value- value object.
-
bitOr
Modify integer attribute.- Parameters:
key- target key.value- value object.
-
bitXor
Modify integer attribute.- Parameters:
key- target key.value- value object.
-
abortOperations
public void abortOperations()abort all modify operations. Notice: this method doesn't work for AVInstallation. -
removeOperationForKey
-
addNewOperation
protected void addNewOperation(cn.leancloud.ops.ObjectFieldOperation op) -
generateChangedParam
save/update with server.- Returns:
- json object.
-
extractCascadingObjects
-
generateCascadingSaveObjects
-
extractUnsavedFiles
-
getUnsavedFiles
-
onSaveSuccess
protected void onSaveSuccess() -
onSaveFailure
protected void onSaveFailure() -
onDataSynchronized
protected void onDataSynchronized() -
saveInBackground
Save object in background.- Returns:
- observable instance.
-
saveInBackground
Save object in background.- Parameters:
asAuthenticatedUser- explicit user for request authentication.- Returns:
- observable instance. in general, this method should be invoked in lean engine.
-
saveInBackground
Save object in background.- Parameters:
option- save option.- Returns:
- observable instance.
-
saveInBackground
public io.reactivex.Observable<? extends LCObject> saveInBackground(LCUser asAuthenticatedUser, LCSaveOption option) Save object in background.- Parameters:
asAuthenticatedUser- explicit user for request authentication.option- save option.- Returns:
- observable instance. in general, this method should be invoked in lean engine.
-
hasCircleReference
judge operations' value include circle reference or not. notice: internal used, pls not invoke it.- Parameters:
markMap- markup map.- Returns:
- flag to indicate there is circle reference or not.
-
save
public void save()Save in blocking mode. -
save
Save in blocking mode.- Parameters:
asAuthenticatedUser- explicit user for request authentication. in general, this method should be invoked in lean engine.
-
saveAll
Save All objects in blocking mode.- Parameters:
objects- object collection.- Throws:
LCException- error happened.
-
saveAll
public static void saveAll(LCUser asAuthenticatedUser, Collection<? extends LCObject> objects) throws LCException Save All objects in blocking mode.- Parameters:
asAuthenticatedUser- explicit user for request authentication.objects- object collection.- Throws:
LCException- error happened. in general, this method should be invoked in lean engine.
-
saveAllInBackground
public static io.reactivex.Observable<JSONArray> saveAllInBackground(Collection<? extends LCObject> objects) Save all objects in async mode.- Parameters:
objects- object collection.- Returns:
- observable instance.
-
saveAllInBackground
public static io.reactivex.Observable<JSONArray> saveAllInBackground(LCUser asAuthenticatedUser, Collection<? extends LCObject> objects) Save all objects in async mode.- Parameters:
asAuthenticatedUser- explicit user for request authentication.objects- object collection.- Returns:
- observable instance. in general, this method should be invoked in lean engine.
-
saveEventually
Save eventually.- Throws:
LCException- error happened.
-
saveEventually
Save eventually.- Parameters:
asAuthenticatedUser- explicit user for request authentication.- Throws:
LCException- error happened. in general, this method should be invoked in lean engine.
-
deleteEventually
public void deleteEventually()Delete current object eventually. -
deleteEventually
Delete current object eventually.- Parameters:
asAuthenticatedUser- explicit user for request authentication. in general, this method should be invoked in lean engine.
-
deleteInBackground
Delete current object in async mode.- Returns:
- observable instance.
-
deleteInBackground
Delete current object in async mode.- Parameters:
asAuthenticatedUser- explicit user for request authentication.- Returns:
- observable instance. in general, this method should be invoked in lean engine.
-
delete
public void delete()Delete current object in blocking mode. -
delete
Delete current object in blocking mode.- Parameters:
asAuthenticatedUser- explicit user for request authentication. in general, this method should be invoked in lean engine.
-
deleteAll
Delete all objects in blocking mode.- Parameters:
objects- object collection.- Throws:
LCException- error happened.
-
deleteAll
public static void deleteAll(LCUser asAuthenticatedUser, Collection<? extends LCObject> objects) throws LCException Delete all objects in blocking mode.- Parameters:
asAuthenticatedUser- explicit user for request authentication.objects- object collection.- Throws:
LCException- error happened. in general, this method should be invoked in lean engine.
-
deleteAllInBackground
public static io.reactivex.Observable<LCNull> deleteAllInBackground(Collection<? extends LCObject> objects) Delete all objects in async mode.- Parameters:
objects- object collection.- Returns:
- observable instance.
-
deleteAllInBackground
public static io.reactivex.Observable<LCNull> deleteAllInBackground(LCUser asAuthenticatedUser, Collection<? extends LCObject> objects) Delete all objects in async mode.- Parameters:
asAuthenticatedUser- explicit user for request authentication.objects- object collection.- Returns:
- observable instance. in general, this method should be invoked in lean engine.
-
refresh
public void refresh()Refresh current object in blocking mode. -
refresh
Refresh current object in blocking mode.- Parameters:
includeKeys- include keys, which object will be return together.
-
refresh
Refresh current object in blocking mode.- Parameters:
asAuthenticatedUser- explicit user for request authentication.includeKeys- include keys, which object will be return together. in general, this method should be invoked in lean engine.
-
refreshInBackground
Refresh current object in async mode.- Returns:
- observable instance.
-
refreshInBackground
Refresh current object in async mode.- Parameters:
asAuthenticatedUser- explicit user for request authentication.- Returns:
- observable instance. in general, this method should be invoked in lean engine.
-
refreshInBackground
Refresh current object in async mode.- Parameters:
includeKeys- include keys, which object will be return together.- Returns:
- observable instance.
-
refreshInBackground
public io.reactivex.Observable<LCObject> refreshInBackground(LCUser asAuthenticatedUser, String includeKeys) Refresh current object in async mode.- Parameters:
asAuthenticatedUser- explicit user for request authentication.includeKeys- include keys, which object will be return together.- Returns:
- observable instance. in general, this method should be invoked in lean engine.
-
fetch
Fetch current object in blocking mode.- Returns:
- current object.
-
fetch
Fetch current object in blocking mode.- Parameters:
includeKeys- include keys, which object will be return together.- Returns:
- current object.
-
fetch
Fetch current object in blocking mode.- Parameters:
asAuthenticatedUser- explicit user for request authentication.includeKeys- include keys, which object will be return together.- Returns:
- current object. in general, this method should be invoked in lean engine.
-
fetchInBackground
Fetch current object in async mode.- Returns:
- observable instance.
-
fetchInBackground
Fetch current object in async mode.- Parameters:
includeKeys- include keys, which object will be return together.- Returns:
- observable instance.
-
fetchInBackground
public io.reactivex.Observable<LCObject> fetchInBackground(LCUser asAuthenticatedUser, String includeKeys) Fetch current object in async mode.- Parameters:
asAuthenticatedUser- explicit user for request authentication.includeKeys- include keys, which object will be return together.- Returns:
- observable instance. in general, this method should be invoked in lean engine.
-
fetchIfNeededInBackground
Fetch current object if needed in async mode.- Returns:
- observable instance.
-
fetchIfNeededInBackground
Fetch current object if needed in async mode.- Parameters:
includeKeys- include keys, which object will be return together.- Returns:
- observable instance.
-
fetchIfNeededInBackground
public io.reactivex.Observable<LCObject> fetchIfNeededInBackground(LCUser asAuthenticatedUser, String includeKeys) Fetch current object if needed in async mode.- Parameters:
asAuthenticatedUser- explicit user for request authentication.includeKeys- include keys, which object will be return together.- Returns:
- observable instance. in general, this method should be invoked in lean engine.
-
fetchIfNeeded
Fetch current object in blocking mode.- Returns:
- current object.
-
resetAll
protected void resetAll() -
resetByRawData
-
resetServerData
Reset server data with new data.- Parameters:
data- new data.
-
getRequestRawEndpoint
Get request endpoint.- Returns:
- endpoint.
-
getRequestMethod
Get request method.- Returns:
- http method.
-
registerSubclass
Register subclass to AVOSCloud SDK.It must be invocated before AVOSCloud.initialize.- Type Parameters:
T- template type.- Parameters:
clazz- The subclass.- Since:
- 1.3.6
-
getACL
get ACL- Returns:
- acl object.
-
setACL
Set ACL- Parameters:
acl- acl object.
-
generateACLFromServerData
-
getQuery
Get query for class.- Type Parameters:
T- result type.- Parameters:
clazz- target class.- Returns:
- query instance.
-
toJSONObject
Generate a new json object with server data.- Returns:
- json object.
-
toJSONString
Generate a json string.- Returns:
- json string.
-
parseLCObject
Create AVObject instance from json string which generated by AVObject.toString or AVObject.toJSONString.- Parameters:
objectString- json string.- Returns:
- AVObject instance, null if objectString is null
-
createWithoutData
Create a new instance with particular classname and objectId.- Parameters:
className- class nameobjectId- object id- Returns:
- AVObject instance
-
createWithoutData
public static <T extends LCObject> T createWithoutData(Class<T> clazz, String objectId) throws LCException Create a new instance with particular class and objectId.- Type Parameters:
T- template type.- Parameters:
clazz- class infoobjectId- object id- Returns:
- AVObject instance
- Throws:
LCException- error happened.
-
disableBeforeHook
public void disableBeforeHook()disable beforeXXX Hooks -
disableAfterHook
public void disableAfterHook()disable afterXXX Hooks -
ignoreHook
ignore specified Hook- Parameters:
hook- target Hook.
-
cast
- Throws:
Exception
-
toString
-
equals
-
hashCode
public int hashCode()
-