}
public static DBObject applyFieldFilter(DBObject object, final Set<String> includeFields, final Set<String> excludeFields) {
if (object instanceof GridFSFile) {
GridFSFile file = (GridFSFile) object;
DBObject metadata = file.getMetaData();
if (metadata != null) {
file.setMetaData(applyFieldFilter(metadata, includeFields, excludeFields));
}
} else {
object = MongoDBHelper.applyExcludeFields(object, excludeFields);
object = MongoDBHelper.applyIncludeFields(object, includeFields);
}