org.ektorp.util
Class Documents
java.lang.Object
org.ektorp.util.Documents
public final class Documents
- extends Object
Class for handling id and revision for persistent classes.
A persistent class must either declare setters and getters for the properties id and revision or
annotate equivalent methods with org.codehaus.jackson.annotate.JsonProperty("_id") and JsonProperty("_rev")
Map can be used as a document class, the map must contain the id field with key "_id" and revision with the key "_rev".
org.codehaus.jackson.node.ObjectNode can olso be used as a document class.
For special needs, a custom document accessor can be registered through the method registerAccessor(Class> documentType, DocumentAccessor accessor)
- Author:
- henrik lundgren, bjohnson.professional, Pascal Gélinas (issue 99)
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Documents
public Documents()
registerAccessor
public static void registerAccessor(Class<?> documentType,
DocumentAccessor accessor)
- Used to register a custom DocumentAccessor for a particular class.
Any existing accessor for the class will be overridden.
- Parameters:
documentType
- accessor
-
getId
public static String getId(Object document)
setId
public static void setId(Object document,
String id)
- Will set the id property on the document IF a mutator exists. Otherwise
nothing happens.
- Parameters:
document
- id
-
getRevision
public static String getRevision(Object document)
setRevision
public static void setRevision(Object document,
String rev)
isNew
public static boolean isNew(Object document)
Copyright © 2011. All Rights Reserved.