public class GetResult extends Object
Modifier and Type | Field and Description |
---|---|
protected byte[] |
content
The encoded content when loading the document.
|
protected int |
flags
The flags from the kv operation.
|
protected Transcoder |
transcoder
The default transcoder which should be used.
|
Modifier and Type | Method and Description |
---|---|
long |
cas()
Returns the CAS value of document at the time of loading.
|
<T> T |
contentAs(Class<T> target)
Decodes the content of the document into an instance of the target class.
|
<T> T |
contentAs(TypeRef<T> target)
Decodes the content of the document into an instance of the target type.
|
JsonArray |
contentAsArray()
Decodes the content of the document into a
JsonArray . |
JsonObject |
contentAsObject()
Decodes the content of the document into a
JsonObject . |
protected String |
convertContentToString()
Converts the content to a string representation if possible (for toString).
|
boolean |
equals(Object o) |
Optional<Duration> |
expiry()
Deprecated.
|
Optional<Instant> |
expiryTime()
If the document has an expiry, returns the point in time when the loaded
document expires.
|
int |
hashCode() |
String |
toString() |
protected final byte[] content
protected final int flags
protected final Transcoder transcoder
public long cas()
The CAS value is an opaque identifier which is associated with a specific state of the document on the server. It can be used during a subsequent mutation to make sure that the document has not been modified in the meantime.
If document on the server has been modified in the meantime the SDK will raise a CasMismatchException
. In
this case the caller is expected to re-do the whole "fetch-modify-update" cycle again. Please refer to the
SDK documentation for more information on CAS mismatches and subsequent retries.
@Deprecated public Optional<Duration> expiry()
In other words, the number of seconds in the returned duration is equal to the epoch second when the document expires.
NOTE: This method always returns an empty Optional unless
the Get request was made using GetOptions.withExpiry(boolean)
set to true.
public Optional<Instant> expiryTime()
NOTE: This method always returns an empty Optional unless
the Get request was made using GetOptions.withExpiry(boolean)
set to true.
public JsonObject contentAsObject()
JsonObject
.public JsonArray contentAsArray()
JsonArray
.public <T> T contentAs(Class<T> target)
target
- the target class to decode the encoded content into.public <T> T contentAs(TypeRef<T> target)
List<String> strings = result.contentAs(new TypeRef<List<String>>(){});
target
- the type to decode the encoded content into.protected String convertContentToString()
Copyright © 2021 Couchbase, Inc.. All rights reserved.