@InterfaceStability.Uncommitted @InterfaceAudience.Private public class SubdocOperationResult<OPERATION> extends Object
Internally represent result corresponding to a single LookupSpec
or MutationSpec
, as part of a DocumentFragment
.
Modifier and Type | Method and Description |
---|---|
static <OPERATION> |
createError(String path,
OPERATION operation,
ResponseStatus status,
CouchbaseException exception)
Create a
SubdocOperationResult that correspond to a subdoc-level error, to be thrown by the enclosing DocumentFragment when calling content methods . |
static <OPERATION> |
createFatal(String path,
OPERATION operation,
RuntimeException fatal)
Create a
SubdocOperationResult that denotes that a fatal Exception occurred when parsing server-side result. |
static <OPERATION> |
createResult(String path,
OPERATION operation,
ResponseStatus status,
Object value)
Create a
SubdocOperationResult that corresponds to an operation that should return a content (including null) instead of throwing when calling DocumentFragment.content(String) . |
static <OPERATION> |
createResult(String path,
OPERATION operation,
ResponseStatus status,
Object value,
byte[] rawValue)
Create a
SubdocOperationResult that corresponds to an operation that should return a content (including null) instead of throwing when calling DocumentFragment.content(String) . |
boolean |
exists() |
boolean |
isFatal() |
OPERATION |
operation() |
String |
path() |
byte[] |
rawValue()
Returns the serialized form of the value of a successful GET, as an array of bytes, or null for any other case, including when the raw value isn’t relevant.
|
ResponseStatus |
status() |
String |
toString() |
Object |
value()
Returns: - the value retrieved by a successful GET.
|
public static <OPERATION> SubdocOperationResult<OPERATION> createFatal(String path, OPERATION operation, RuntimeException fatal)
Create a SubdocOperationResult
that denotes that a fatal Exception occurred when parsing server-side result. The exception can be found as the value, and the status is ResponseStatus.FAILURE
.
path
- the path looked up.operation
- the type of the operation which result couldn’t be parsed.fatal
- the Exception that occurred during response parsing.public static <OPERATION> SubdocOperationResult<OPERATION> createResult(String path, OPERATION operation, ResponseStatus status, Object value)
Create a SubdocOperationResult
that corresponds to an operation that should return a content (including null) instead of throwing when calling DocumentFragment.content(String)
.
path
- the path looked up.operation
- the type of operation.status
- the status of the operation.value
- the value of the operation if applicable, null otherwise.public static <OPERATION> SubdocOperationResult<OPERATION> createResult(String path, OPERATION operation, ResponseStatus status, Object value, byte[] rawValue)
Create a SubdocOperationResult
that corresponds to an operation that should return a content (including null) instead of throwing when calling DocumentFragment.content(String)
. Additionally, the result can also contain a raw byte representation of the same content in serialized form.
path
- the path looked up.operation
- the type of operation.status
- the status of the operation.value
- the value of the operation if applicable, null otherwise.rawValue
- the raw byte value of the operation if applicable, null otherwise.public static <OPERATION> SubdocOperationResult<OPERATION> createError(String path, OPERATION operation, ResponseStatus status, CouchbaseException exception)
Create a SubdocOperationResult
that correspond to a subdoc-level error, to be thrown by the enclosing DocumentFragment when calling content methods
.
path
- the path looked up.operation
- the type of operation.status
- the status of the operation.exception
- the exception to throw when trying to access the operation content.public String path()
public OPERATION operation()
public ResponseStatus status()
public boolean exists()
public Object value()
Returns: - the value retrieved by a successful GET. - null for an unsuccessful GET (see the status()
for details). - true/false for an EXIST (equivalent to exists()
). - a RuntimeException
if the client side parsing of the result failed (isFatal()
).
public byte[] rawValue()
Returns the serialized form of the value of a successful GET, as an array of bytes, or null for any other case, including when the raw value isn’t relevant.
public boolean isFatal()
value()
returns an RuntimeException
.Copyright © 2015 Couchbase, Inc.