Package com.couchbase.client.java.kv
Class GetResult
- java.lang.Object
-
- com.couchbase.client.java.kv.GetResult
-
- Direct Known Subclasses:
GetReplicaResult
public class GetResult extends Object
Returned from all kinds of KeyValue Get operation to fetch a document or a subset of it.- Since:
- 3.0.0
-
-
Field Summary
Fields Modifier and Type Field 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.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description long
cas()
Returns the CAS value of the loaded document.<T> T
contentAs(TypeRef<T> target)
Decodes the content of the document into an instance of the target type.<T> T
contentAs(Class<T> target)
Decodes the content of the document into an instance of the target class.JsonArray
contentAsArray()
Decodes the content of the document into aJsonArray
.JsonObject
contentAsObject()
Decodes the content of the document into aJsonObject
.protected String
convertContentToString()
Converts the content to a string representation if possible (for toString).boolean
equals(Object o)
Optional<Duration>
expiry()
If present, returns the expiry of the loaded document.int
hashCode()
String
toString()
-
-
-
Field Detail
-
content
protected final byte[] content
The encoded content when loading the document.
-
flags
protected final int flags
The flags from the kv operation.
-
transcoder
protected final Transcoder transcoder
The default transcoder which should be used.
-
-
Method Detail
-
cas
public long cas()
Returns the CAS value of the loaded document.
-
expiry
public Optional<Duration> expiry()
If present, returns the expiry of the loaded document.Note that the duration represents the time when the document has been loaded and can only ever be an approximation.
-
contentAsObject
public JsonObject contentAsObject()
Decodes the content of the document into aJsonObject
.
-
contentAsArray
public JsonArray contentAsArray()
Decodes the content of the document into aJsonArray
.
-
contentAs
public <T> T contentAs(Class<T> target)
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
public <T> T contentAs(TypeRef<T> target)
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.
-
convertContentToString
protected String convertContentToString()
Converts the content to a string representation if possible (for toString).
-
-