@Deprecated
    @SuppressWarnings("unchecked")
    public AggregationOutput aggregate(final List<? extends DBObject> pipeline, final ReadPreference readPreference) {
        Cursor cursor = aggregate(pipeline, AggregationOptions.builder().build(), readPreference, false);

        if (cursor == null) {
            return new AggregationOutput(Collections.<DBObject>emptyList());
        } else {
            List<DBObject> results = new ArrayList<DBObject>();
            while (cursor.hasNext()) {
                results.add(cursor.next());
            }
            return new AggregationOutput(results);
        }
    }
@Deprecated
    @SuppressWarnings("unchecked")
    public AggregationOutput aggregate(final List<? extends DBObject> pipeline, final ReadPreference readPreference) {
        Cursor cursor = aggregate(pipeline, AggregationOptions.builder().build(), readPreference, false);

        if (cursor == null) {
            return new AggregationOutput(Collections.<DBObject>emptyList());
        } else {
            List<DBObject> results = new ArrayList<DBObject>();
            while (cursor.hasNext()) {
                results.add(cursor.next());
            }
            return new AggregationOutput(results);
        }
    }
@ Deprecated @ SuppressWarnings ( "unchecked" ) public AggregationOutput aggregate ( final List < ? extends DBObject > pipeline , final ReadPreference readPreference ) { Cursor cursor = aggregate ( pipeline , AggregationOptions . builder ( ) . build ( ) , readPreference , false ) ; if ( cursor == null ) { return new AggregationOutput ( Collections . < DBObject > emptyList ( ) ) ; } else { List < DBObject > results = new ArrayList < DBObject > ( ) ; while ( cursor . hasNext ( ) ) { results . add ( cursor . next ( ) ) ; } return new AggregationOutput ( results ) ; } }
Method implements aggregation framework.

@param pipeline       operations to be performed in the aggregation pipeline
@param readPreference the read preference specifying where to run the query
@return the aggregation's result set
@mongodb.driver.manual core/aggregation-pipeline/ Aggregation
@mongodb.server.release 2.2
@deprecated Use {@link #aggregate(List, AggregationOptions, ReadPreference)} )} instead
Method implements aggregation framework .