static BsonDocument getVersionedFilter ( @ Nonnull final BsonValue documentId , @ Nullable final BsonValue version ) { final BsonDocument filter = new BsonDocument ( "_id" , documentId ) ; if ( version == null ) { filter . put ( DOCUMENT_VERSION_FIELD , new BsonDocument ( "$exists" , BsonBoolean . FALSE ) ) ; } else { filter . put ( DOCUMENT_VERSION_FIELD , version ) ; } return filter ; }
Returns a query filter for the given document _id and version . The version is allowed to be null . The query will match only if there is either no version on the document in the database in question if we have no reference of the version or if the version matches the database s version .