/** * Confirms that the given bson object only contains fields whose names given. * * @param objectName the container's name, that will be included in the error messages * @param bson the object whose fields are going to be checked * @param fields the fields we are going to accept * @throws BadValueException if an unexpected field is found */ public static void checkOnlyHasFields( String objectName, BsonDocument bson, String... fields) throws BadValueException { checkOnlyHasFields(objectName, bson, Sets.newHashSet(fields)); }