@ SuppressWarnings ( { "rawtypes" , "unchecked" } ) public static BsonDocument asBsonDocument ( final Object document , final CodecRegistry codecRegistry ) { if ( document == null ) { return null ; } if ( document instanceof BsonDocument ) { return ( BsonDocument ) document ; } else { return new BsonDocumentWrapper ( document , codecRegistry . get ( document . getClass ( ) ) ) ; } }
A helper to convert an document of type Object to a BsonDocument