@InterfaceStability.Experimental @InterfaceAudience.Public public class DocumentFragment<T> extends Object
A fragment of a JSON Document
that can be any JSON value (including String, JsonObject
, JsonArray
, etc…), as returned and used in the sub-document API.
Modifier and Type | Method and Description |
---|---|
long |
cas()
The CAS (Create-and-Set) value can either be set by the user when the DocumentFragment is the input for a mutation, or by the SDK when it is the return value of a subdoc operation.
|
static <T> DocumentFragment<T> |
create(String id,
String path,
int expiry,
T fragment)
Creates a new
DocumentFragment (id, path and fragment) to represent a mutation input (with expiry). |
static <T> DocumentFragment<T> |
create(String id,
String path,
int expiry,
T fragment,
long cas)
Creates a new
DocumentFragment (id, path and fragment) to represent a mutation input using optimistic locking (CAS). |
static <T> DocumentFragment<T> |
create(String id,
String path,
int expiry,
T fragment,
long cas,
MutationToken mutationToken)
Creates a new
DocumentFragment (id, path and fragment) to represent a mutation result (with expiry, cas and mutationToken). |
static <T> DocumentFragment<T> |
create(String id,
String path,
T fragment)
Creates a new
DocumentFragment (id, path and fragment) to represent a simple mutation input. |
static <T> DocumentFragment<T> |
create(String id,
String path,
T fragment,
long cas)
Creates a new
DocumentFragment (id, path and fragment) to represent a mutation input using optimistic locking (CAS). |
boolean |
equals(Object o) |
int |
expiry() |
T |
fragment() |
int |
hashCode() |
String |
id() |
MutationToken |
mutationToken() |
String |
path() |
String |
toString() |
@InterfaceAudience.Private public static <T> DocumentFragment<T> create(String id, String path, int expiry, T fragment, long cas, MutationToken mutationToken)
Creates a new DocumentFragment
(id, path and fragment) to represent a mutation result (with expiry, cas and mutationToken).
This is usually only used internally, for return value of subdocument mutations, as the mutationToken is populated through the analysis of a server response.
id
- the id of the document that was mutated.path
- the path at which the mutation occurred.expiry
- the new expiry that was requested along the mutation, or 0L if not changed (document could still have been previously set to expire).fragment
- the new value after mutation (could be null in case of a delete).cas
- the new CAS value after mutation.mutationToken
- the MutationToken
that marks this mutation if available, null otherwise.T
- the type of the fragment content.public static <T> DocumentFragment<T> create(String id, String path, int expiry, T fragment)
Creates a new DocumentFragment
(id, path and fragment) to represent a mutation input (with expiry).
id
- the id of the document to be mutated.path
- the path at which the mutation should occur.expiry
- the new expiry requested along the mutation, or 0L to ignore (document could still have been previously set to expire).fragment
- the new value after mutation (could be null in case of a delete).T
- the type of the fragment content.public static <T> DocumentFragment<T> create(String id, String path, T fragment, long cas)
Creates a new DocumentFragment
(id, path and fragment) to represent a mutation input using optimistic locking (CAS).
id
- the id of the document to be mutated.path
- the path at which the mutation should occur.fragment
- the new value after mutation (could be null in case of a delete).cas
- the expected CAS value to be matched with the document’s CAS to validate the mutation.T
- the type of the fragment content.public static <T> DocumentFragment<T> create(String id, String path, int expiry, T fragment, long cas)
Creates a new DocumentFragment
(id, path and fragment) to represent a mutation input using optimistic locking (CAS).
id
- the id of the document to be mutated.path
- the path at which the mutation should occur.expiry
- the new expiry requested along the mutation, or 0L to ignore (document could still have been previously set to expire).fragment
- the new value after mutation (could be null in case of a delete).cas
- the expected CAS value to be matched with the document’s CAS to validate the mutation.T
- the type of the fragment content.public static <T> DocumentFragment<T> create(String id, String path, T fragment)
Creates a new DocumentFragment
(id, path and fragment) to represent a simple mutation input. No optimistic locking is performed and the enclosing document’s expiration is not modified.
id
- the id of the document to be mutated.path
- the path at which the mutation should occur.fragment
- the new value after mutation (could be null in case of a delete).T
- the type of the fragment content.public String id()
id
of the enclosing JSON document in which this fragment belongs.public String path()
public T fragment()
public long cas()
The CAS (Create-and-Set) value can either be set by the user when the DocumentFragment is the input for a mutation, or by the SDK when it is the return value of a subdoc operation.
When the fragment is used as an input parameter to a mutation, the CAS will be compared to the one of the target enclosing JSON document
and mutation only applied if both CAS match.
When the fragment is the return value of the operation, the CAS is populated with the one from the enclosing JSON document.
public int expiry()
public MutationToken mutationToken()
MutationToken
related to the enclosing JSON document after a mutation (when the fragment is the return value of said mutation).Copyright © 2015 Couchbase, Inc.