* the {@link RiakObject} to convert
* @return
*/
static IRiakObject convert(final com.basho.riak.client.http.RiakObject o) {
RiakObjectBuilder builder = RiakObjectBuilder.newBuilder(o.getBucket(), o.getKey());
builder.withValue(o.getValueAsBytes());
builder.withVClock(nullSafeGetBytes(o.getVclock()));
builder.withVtag(o.getVtag());
builder.withDeleted(o.isDeleted());
String lastModified = o.getLastmod();
if (lastModified != null) {
Date lastModDate = o.getLastmodAsDate();
builder.withLastModified(lastModDate.getTime());
}
final Collection<RiakLink> links = new ArrayList<RiakLink>();
for (com.basho.riak.client.http.RiakLink link : o.iterableLinks()) {
links.add(convert(link));
}
builder.withLinks(links);
@SuppressWarnings("rawtypes") final Collection<com.basho.riak.client.http.RiakIndex> indexes = o.getIndexes();
for (@SuppressWarnings("rawtypes") com.basho.riak.client.http.RiakIndex i : indexes) {
if (i instanceof com.basho.riak.client.http.IntIndex) {
builder.addIndex(i.getName(), (Long) i.getValue());
}
if (i instanceof com.basho.riak.client.http.BinIndex) {
builder.addIndex(i.getName(), (String) i.getValue());
}
}
builder.withContentType(o.getContentType());
final Map<String, String> userMetaData = new HashMap<String, String>();
for (String key : o.usermetaKeys()) {
userMetaData.put(key, o.getUsermetaItem(key));
}
builder.withUsermeta(userMetaData);
return builder.build();
}