@Override
 public void serialize(UUID value, JsonGenerator jgen, SerializerProvider provider)
     throws IOException, JsonProcessingException {
   if (!(jgen instanceof BsonGenerator)) {
     throw new JsonGenerationException("BsonUuidSerializer can only be used with BsonGenerator");
   }
   ((BsonGenerator) jgen)
       .writeBinary(null, BsonConstants.SUBTYPE_UUID, uuidToLittleEndianBytes(value), 0, 16);
 }
 @Override
 public void serialize(UUID value, BsonGenerator bgen, SerializerProvider provider)
     throws IOException {
   bgen.writeBinary(null, BsonConstants.SUBTYPE_UUID, uuidToLittleEndianBytes(value), 0, 16);
 }