Package com.couchbase.client.java.subdoc
Class SubdocOperationResult<OPERATION>
java.lang.Object
com.couchbase.client.java.subdoc.SubdocOperationResult<OPERATION>
@Uncommitted @Private public class SubdocOperationResult<OPERATION> extends Object
Internally represent result corresponding to a single
LookupSpec
or MutationSpec
,
as part of a DocumentFragment
.- Since:
- 2.2
- Author:
- Simon Baslé
-
Method Summary
Modifier and Type Method Description static <OPERATION>
SubdocOperationResult<OPERATION>createError(String path, OPERATION operation, ResponseStatus status, CouchbaseException exception)
Create aSubdocOperationResult
that correspond to a subdoc-level error, to be thrown by the enclosingDocumentFragment when calling content methods
.static <OPERATION>
SubdocOperationResult<OPERATION>createFatal(String path, OPERATION operation, RuntimeException fatal)
Create aSubdocOperationResult
that denotes that a fatal Exception occurred when parsing server-side result.static <OPERATION>
SubdocOperationResult<OPERATION>createResult(String path, OPERATION operation, ResponseStatus status, Object value)
Create aSubdocOperationResult
that corresponds to an operation that should return a content (including null) instead of throwing when callingDocumentFragment.content(String)
.static <OPERATION>
SubdocOperationResult<OPERATION>createResult(String path, OPERATION operation, ResponseStatus status, Object value, byte[] rawValue)
Create aSubdocOperationResult
that corresponds to an operation that should return a content (including null) instead of throwing when callingDocumentFragment.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.
-
Method Details
-
createFatal
public static <OPERATION> SubdocOperationResult<OPERATION> createFatal(String path, OPERATION operation, RuntimeException fatal)Create aSubdocOperationResult
that denotes that a fatal Exception occurred when parsing server-side result. The exception can be found as the value, and the status isResponseStatus.FAILURE
.- Parameters:
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.- Returns:
- the fatal LookupResult.
-
createResult
public static <OPERATION> SubdocOperationResult<OPERATION> createResult(String path, OPERATION operation, ResponseStatus status, Object value)Create aSubdocOperationResult
that corresponds to an operation that should return a content (including null) instead of throwing when callingDocumentFragment.content(String)
.- Parameters:
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.- Returns:
- the operation result.
-
createResult
public static <OPERATION> SubdocOperationResult<OPERATION> createResult(String path, OPERATION operation, ResponseStatus status, Object value, byte[] rawValue)Create aSubdocOperationResult
that corresponds to an operation that should return a content (including null) instead of throwing when callingDocumentFragment.content(String)
. Additionally, the result can also contain a raw byte representation of the same content in serialized form.- Parameters:
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.- Returns:
- the operation result.
-
createError
public static <OPERATION> SubdocOperationResult<OPERATION> createError(String path, OPERATION operation, ResponseStatus status, CouchbaseException exception)Create aSubdocOperationResult
that correspond to a subdoc-level error, to be thrown by the enclosingDocumentFragment when calling content methods
.- Parameters:
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.- Returns:
- the operation result.
-
path
- Returns:
- the path that was looked up.
-
operation
- Returns:
- the exact kind of lookup that was performed.
-
status
- Returns:
- the status of the lookup.
-
exists
public boolean exists()- Returns:
- true if the value existed (and might have associated value), false otherwise.
-
value
Returns: - the value retrieved by a successful GET. - null for an unsuccessful GET (see thestatus()
for details). - true/false for an EXIST (equivalent toexists()
). - aRuntimeException
if the client side parsing of the result failed (isFatal()
).- Returns:
- the value
-
rawValue
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.- Returns:
- the serialized raw value, if available.
-
isFatal
public boolean isFatal()- Returns:
- true if there was a fatal error while processing the result on the client side, in which case
value()
returns anRuntimeException
.
-
toString
-