public interface NitriteMapper
Represents an object mapper for nitrite database. It
converts an object into a Nitrite Document.
| 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. |
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
|
<T> Document asDocument(T object)
Converts and object to a Document.
T - the type parameterobject - the objectObjectMappingException - if circular reference found.<T> T asObject(Document document, java.lang.Class<T> type)
Tries to convert a document to an object of type T.
T - the type parameterdocument - the documenttype - the type of the objectjava.lang.IllegalArgumentException - if conversion fails due to incompatible type.ObjectMappingException - if no public parameter-less constructor found.boolean isValueType(java.lang.Object object)
Determines if an object would be stored as a value type.
object - the object to checktrue of object would be stored as a value type; false otherwise.java.lang.Object asValue(java.lang.Object object)
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.
|
object - the object to convertDocument parse(java.lang.String json)
Parses a json string into a nitrite Document.
json - the json string to parsejava.lang.String toJson(java.lang.Object object)
Serializes an object to a json string
object - the object