public class JacksonMapper extends java.lang.Object implements NitriteMapper
A jackson based NitriteMapper
implementation. It uses
jackson’s ObjectMapper
to convert an object into a
Nitrite Document
.
Constructor and Description |
---|
JacksonMapper() |
Modifier and Type | Method and Description |
---|---|
<T> Document |
asDocument(T object)
Converts and
object to a Document . |
<T> T |
asObject(Document document,
java.lang.Class<T> type)
Tries to convert a
document to an object of type T . |
java.lang.Object |
asValue(java.lang.Object object)
Tries to convert an
object to a value type, which will be stored in
the document. |
com.fasterxml.jackson.databind.ObjectMapper |
getObjectMapper()
Gets the underlying
ObjectMapper instance to configure. |
boolean |
isValueType(java.lang.Object object)
Determines if an object would be stored as a value type.
|
Document |
parse(java.lang.String json)
Parses a json string into a nitrite
Document . |
java.lang.String |
toJson(java.lang.Object object)
Serializes an object to a json string
|
public <T> Document asDocument(T object)
NitriteMapper
Converts and object
to a Document
.
asDocument
in interface NitriteMapper
T
- the type parameterobject
- the objectpublic <T> T asObject(Document document, java.lang.Class<T> type)
NitriteMapper
Tries to convert a document
to an object of type T
.
asObject
in interface NitriteMapper
T
- the type parameterdocument
- the documenttype
- the type of the objectpublic boolean isValueType(java.lang.Object object)
NitriteMapper
Determines if an object would be stored as a value type.
isValueType
in interface NitriteMapper
object
- the object to checktrue
of object
would be stored as a value type; false
otherwise.public java.lang.Object asValue(java.lang.Object object)
NitriteMapper
Tries to convert an object
to a value type, which will be stored in
the document.
As an example, a Date object is stored
as a Long value in the document. This operation
will return the long value of a Date object.
|
asValue
in interface NitriteMapper
object
- the object to convertpublic Document parse(java.lang.String json)
NitriteMapper
Parses a json string into a nitrite Document
.
parse
in interface NitriteMapper
json
- the json string to parsepublic java.lang.String toJson(java.lang.Object object)
NitriteMapper
Serializes an object to a json string
toJson
in interface NitriteMapper
object
- the objectpublic com.fasterxml.jackson.databind.ObjectMapper getObjectMapper()
Gets the underlying ObjectMapper
instance to configure.