Search in sources :

Example 1 with ByteArrayKvMongoObjectId

use of com.torodb.kvdocument.values.heap.ByteArrayKvMongoObjectId in project torodb by torodb.

the class MapToKvValueConverter method buildSpecialObject.

private KvValue<?> buildSpecialObject(Map<String, Object> map) {
    Entry<String, Object> first = map.entrySet().iterator().next();
    String key = first.getKey();
    Object value = first.getValue();
    if ("$oid".equals(key) && value instanceof String) {
        return new ByteArrayKvMongoObjectId(HexUtils.hex2Bytes((String) value));
    }
    if ("$date".equals(key)) {
        return parseDate(key, value);
    }
    throw new RuntimeException("Unexpected special object type: " + key);
}
Also used : ByteArrayKvMongoObjectId(com.torodb.kvdocument.values.heap.ByteArrayKvMongoObjectId) StringKvString(com.torodb.kvdocument.values.heap.StringKvString)

Example 2 with ByteArrayKvMongoObjectId

use of com.torodb.kvdocument.values.heap.ByteArrayKvMongoObjectId in project torodb by torodb.

the class PostgreSqlValueToCopyConverterTest method testMongoObjectId.

@Test
public void testMongoObjectId() {
    KvMongoObjectId mongoObjectIdValue = new ByteArrayKvMongoObjectId(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xa, 0xb, 0xc });
    mongoObjectIdValue.accept(visitor, sb);
    assertEquals("\\\\x0102030405060708090A0B0C", sb.toString());
}
Also used : ByteArrayKvMongoObjectId(com.torodb.kvdocument.values.heap.ByteArrayKvMongoObjectId) KvMongoObjectId(com.torodb.kvdocument.values.KvMongoObjectId) ByteArrayKvMongoObjectId(com.torodb.kvdocument.values.heap.ByteArrayKvMongoObjectId) Test(org.junit.Test)

Aggregations

ByteArrayKvMongoObjectId (com.torodb.kvdocument.values.heap.ByteArrayKvMongoObjectId)2 KvMongoObjectId (com.torodb.kvdocument.values.KvMongoObjectId)1 StringKvString (com.torodb.kvdocument.values.heap.StringKvString)1 Test (org.junit.Test)1