public class JacksonFacade extends java.lang.Object implements MapperFacade
A jackson based MapperFacade implementation. It uses
jackson’s ObjectMapper to convert an object into a
Nitrite Document.
| Constructor and Description |
|---|
JacksonFacade()
Instantiates a new
JacksonFacade. |
JacksonFacade(java.util.Set<com.fasterxml.jackson.databind.Module> modules)
Instantiates a new
JacksonFacade. |
| Modifier and Type | Method and Description |
|---|---|
Document |
asDocument(java.lang.Object 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. |
protected com.fasterxml.jackson.databind.ObjectMapper |
createObjectMapper()
Creates a new jackson
ObjectMapper. |
protected com.fasterxml.jackson.databind.ObjectMapper |
createObjectMapper(java.util.Set<com.fasterxml.jackson.databind.Module> modules)
Creates a new jackson
ObjectMapper and registers
Module specified by modules. |
com.fasterxml.jackson.databind.ObjectMapper |
getObjectMapper()
Gets the
ObjectMapper. |
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 JacksonFacade()
Instantiates a new JacksonFacade.
public JacksonFacade(java.util.Set<com.fasterxml.jackson.databind.Module> modules)
Instantiates a new JacksonFacade.
modules - jackson Module to registerprotected com.fasterxml.jackson.databind.ObjectMapper createObjectMapper()
Creates a new jackson ObjectMapper.
protected com.fasterxml.jackson.databind.ObjectMapper createObjectMapper(java.util.Set<com.fasterxml.jackson.databind.Module> modules)
Creates a new jackson ObjectMapper and registers
Module specified by modules.
modules - jackson Module to registerpublic com.fasterxml.jackson.databind.ObjectMapper getObjectMapper()
Gets the ObjectMapper.
public Document asDocument(java.lang.Object object)
NitriteMapperConverts and object to a Document.
asDocument in interface NitriteMapperobject - the objectpublic <T> T asObject(Document document, java.lang.Class<T> type)
NitriteMapperTries to convert a document to an object of type T.
asObject in interface NitriteMapperT - the type parameterdocument - the documenttype - the type of the objectpublic java.lang.Object asValue(java.lang.Object object)
NitriteMapperTries 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 NitriteMapperobject - the object to convertpublic boolean isValueType(java.lang.Object object)
NitriteMapperDetermines if an object would be stored as a value type.
isValueType in interface NitriteMapperobject - the object to checktrue of object would be stored as a value type; false otherwise.public Document parse(java.lang.String json)
MapperFacadeParses a json string into a nitrite Document.
parse in interface MapperFacadejson - the json string to parsepublic java.lang.String toJson(java.lang.Object object)
MapperFacadeSerializes an object to a json string
toJson in interface MapperFacadeobject - the object