|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.basho.riak.client.convert.JSONConverter<T>
public class JSONConverter<T>
Converts a RiakObject's value to an instance of T. T must have a field
annotated with RiakKey
or you must construct the converter with a key to use. RiakObject's value *must* be a JSON string.
At present user meta data and RiakLink
s are not converted. This means
they are essentially lost in translation.
Constructor Summary | |
---|---|
JSONConverter(Class<T> clazz,
String bucket)
Create a JSONConverter for creating instances of clazz from
JSON and instances of IRiakObject with a JSON payload from
instances of clazz |
|
JSONConverter(Class<T> clazz,
String bucket,
String defaultKey)
Create a JSONConverter for creating instances of clazz from
JSON and instances of IRiakObject with a JSON payload from
instances of clazz |
Method Summary | |
---|---|
IRiakObject |
fromDomain(T domainObject,
VClock vclock)
Converts domainObject to a JSON string and sets that as the
payload of a IRiakObject . |
T |
toDomain(IRiakObject riakObject)
Converts the value of riakObject to an instance
of T . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public JSONConverter(Class<T> clazz, String bucket)
clazz
from
JSON and instances of IRiakObject
with a JSON payload from
instances of clazz
clazz
- the type to convert to/fromb
- the bucketpublic JSONConverter(Class<T> clazz, String bucket, String defaultKey)
clazz
from
JSON and instances of IRiakObject
with a JSON payload from
instances of clazz
clazz
- the type to convert to/frombucket
- the bucketdefaultKey
- for cases where clazz
does not have a
RiakKey
annotated field, pass the key to use in this
conversion.Method Detail |
---|
public IRiakObject fromDomain(T domainObject, VClock vclock) throws ConversionException
domainObject
to a JSON string and sets that as the
payload of a IRiakObject
. Also set the content-type
to application/json;charset=UTF-8
fromDomain
in interface Converter<T>
domainObject
- to be convertedvclock
- the vector clock from Riak
ConversionException
public T toDomain(IRiakObject riakObject) throws ConversionException
value
of riakObject
to an instance
of T
.
Beware: at present links and user meta are not converted at present: this is on the way.
toDomain
in interface Converter<T>
riakObject
- the IRiakObject
to convert to instance of
T
. NOTE: riakObject.getValue()
must be a
JSON string. The charset from
riakObject.getContentType()
is used.
ConversionException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |