@SuppressWarnings("resource")
        @Override
        public List<T> call() throws Exception {
          @Nullable Bson query = criteria != null ? convertToBson(criteria) : null;

          FindIterable<T> cursor = collection().find(query);

          if (!exclusion.isNil()) {
            cursor.projection(convertToBson(exclusion));
          }

          if (!ordering.isNil()) {
            cursor.sort(convertToBson(ordering));
          }

          cursor.skip(skip);

          if (limit != 0) {
            cursor.limit(limit);
            if (limit <= LARGE_BATCH_SIZE) {
              // if limit specified and is smaller than reasonable large batch size
              // then we force batch size to be the same as limit,
              // but negative, this force cursor to close right after result is sent
              cursor.batchSize(-limit);
            }
          }

          // close properly
          try (MongoCursor<T> iterator = cursor.iterator()) {
            return ImmutableList.copyOf(iterator);
          }
        }
Codec used for current collection type.
@return registry
mongo/src/org/immutables/mongo/repository/Repositories.java