Convert the row's content to a Java object by calling as(java.lang.Class<T>)
or asNullable(java.lang.Class<T>)
.
Conversion is done by the Deserializer
specified in the query
options, or by the cluster's default deserializer if none was specified
for the query.
If you use JacksonDeserializer
(the default) and enjoy
working with Jackson's tree model, call row.as(JsonNode.class)
to convert the row to a Jackson tree. Alternatively, pass a class whose
fields match the structure of the row, and let Jackson bind the row data
to a new instance of the class.
Convert to a parameterized type by calling the overload that
takes a TypeRef
instead of a Class. For example:
row.as(new TypeRef<Map<String, MyCustomClass>>() {});
If you prefer to use the Couchbase Columnar SDK's simple JsonValue
tree model, convert the row to JsonObject
or JsonArray
.
These classes are not as full-featured as Jackson's tree model, but they
are always supported regardless of which deserializer you use.
Call bytes()
to get the raw bytes of the row content,
exactly as it was received from the server. This may be useful for
debugging, or if you want to handle deserialization yourself.
- See Also:
-
Method Summary
Modifier and TypeMethodDescription<T> T
Returns the content of the row deserialized as an instance of the specified type.<T> T
Returns the content of the row deserialized as an instance of the specified type.<T> @Nullable T
asNullable
(TypeRef<T> type) Returns the content of the row deserialized as an instance of the specified type, or null if the row content is a literal null.<T> @Nullable T
asNullable
(Class<T> type) Returns the content of the row deserialized as an instance of the specified type, or null if the row's content is a literal null.byte[]
bytes()
Returns the raw content of the row, exactly as it was received from the server.toString()
-
Method Details
-
bytes
public byte[] bytes()Returns the raw content of the row, exactly as it was received from the server.This method returns the same array each time it is called.
-
as
Returns the content of the row deserialized as an instance of the specified type.- Throws:
NullPointerException
- if the row content is a literal null.DataConversionException
- if the row could not be deserialized into an instance of the specified type.
-
asNullable
Returns the content of the row deserialized as an instance of the specified type, or null if the row's content is a literal null.- Throws:
DataConversionException
- if the row could not be deserialized into an instance of the specified type.
-
as
Returns the content of the row deserialized as an instance of the specified type.- Throws:
NullPointerException
- if the row content is a literal null.DataConversionException
- if the row could not be deserialized into an instance of the specified type.
-
asNullable
Returns the content of the row deserialized as an instance of the specified type, or null if the row content is a literal null.- Throws:
DataConversionException
- if the row could not be deserialized into an instance of the specified type.
-
toString
-