public static void marshal(JsonGenerator generator, Id value) throws IOException {
   if (generator instanceof BsonGenerator) {
     ((BsonGenerator) generator)
         .writeObjectId(new ObjectId(value.time(), value.machine(), value.inc()));
   } else {
     generator.writeString(value.toString());
   }
 }
 @Override
 public void serialize(
     ObjectId objectId, BsonGenerator bsonGenerator, SerializerProvider serializerProvider)
     throws IOException {
   if (objectId == null) {
     serializerProvider.defaultSerializeNull(bsonGenerator);
   } else {
     bsonGenerator.writeObjectId(objectId);
   }
 }