de.bild.codec.ObjectIdGenerator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of polymorphia Show documentation
Show all versions of polymorphia Show documentation
A very fast POJO codec for MongoDB (used in conjunction with the Mongo Java Driver) that handles generic types as well as polymorphic class hierarchies
package de.bild.codec;
import org.bson.BsonObjectId;
import org.bson.BsonValue;
import org.bson.types.ObjectId;
public class ObjectIdGenerator implements IdGenerator {
@Override
public ObjectId generate() {
return new ObjectId();
}
@Override
public BsonValue asBsonValue(ObjectId id, TypeCodecRegistry typeCodecRegistry) {
return new BsonObjectId(id);
}
}