@Override public Void visit(BsonObjectId value, ByteBuf arg) { arg.writeBytes(value.toByteArray()); return null; }
@Override public KVValue visit(BsonObjectId value, Void arg) { return new ByteArrayKVMongoObjectId(value.toByteArray()); }
@Override public int compareTo(BsonValue<?> obj) { if (obj == this) { return 0; } int diff = BsonTypeComparator.INSTANCE.compare(getType(), obj.getType()); if (diff != 0) { return diff; } if (obj.isDbPointer()) { return -1; } assert obj instanceof BsonObjectId; BsonObjectId other = obj.asObjectId(); byte[] otherBytes; if (obj instanceof AbstractBsonObjectId) { otherBytes = ((AbstractBsonObjectId) obj).getBytesUnsafe(); } else { otherBytes = other.toByteArray(); } byte[] thisBytes = getBytesUnsafe(); for (int i = 0; i < 12; i++) { diff = (thisBytes[i] & 0xFF) - (otherBytes[i] & 0xFF); if (diff != 0) { return diff; } } return 0; }