Class GetResult
- Direct Known Subclasses:
GetReplicaResult
- Since:
- 3.0.0
-
Field Summary
Modifier and TypeFieldDescriptionprotected final byte[]
The encoded content when loading the document.protected final int
The flags from the kv operation.protected final Transcoder
The default transcoder which should be used. -
Constructor Summary
ConstructorDescriptionGetResult
(byte[] content, int flags, long cas, Optional<Instant> expiry, Transcoder transcoder) Creates a newGetResult
.GetResult
(CoreGetResult core, Transcoder transcoder) -
Method Summary
Modifier and TypeMethodDescriptionlong
cas()
Returns the CAS value of document at the time of loading.<T> T
Decodes the content of the document into an instance of the target type.<T> T
Decodes the content of the document into an instance of the target class.Decodes the content of the document into aJsonArray
.byte[]
Returns the raw bytes of the document content.Decodes the content of the document into aJsonObject
.boolean
expiry()
Deprecated.If the document has an expiry, returns the point in time when the loaded document expires.int
hashCode()
toString()
-
Field Details
-
protected final byte[] contentThe encoded content when loading the document.
-
flags
protected final int flagsThe flags from the kv operation. -
transcoder
The default transcoder which should be used.
-
-
Constructor Details
-
GetResult
@Internal public GetResult(byte[] content, int flags, long cas, Optional<Instant> expiry, Transcoder transcoder) Creates a newGetResult
.- Parameters:
cas
- the cas from the doc.expiry
- the expiry if fetched from the doc.
-
GetResult
-
-
Method Details
-
cas
public long cas()Returns the CAS value of document at the time of loading.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. -
expiry
Deprecated.If the document has an expiry, returns length of time between the start of the epoch and the point in time when the loaded document expires.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. -
expiryTime
If the document has an expiry, returns the point in time when the loaded document expires.NOTE: This method always returns an empty Optional unless the Get request was made using
GetOptions.withExpiry(boolean)
set to true. -
contentAsObject
Decodes the content of the document into aJsonObject
. -
contentAsArray
Decodes the content of the document into aJsonArray
. -
contentAs
Decodes the content of the document into an instance of the target class.- Parameters:
target
- the target class to decode the encoded content into.
-
contentAs
Decodes the content of the document into an instance of the target type. Example usage:List<String> strings = result.contentAs(new TypeRef<List<String>>(){});
- Parameters:
target
- the type to decode the encoded content into.
-
contentAsBytes
Returns the raw bytes of the document content.- Returns:
- the document content as a byte array
-
toString
-
equals
-
hashCode
public int hashCode()
-