driver-legacy/src/main/com/mongodb/DBCollection.java
public Cursor aggregate(final List<? extends DBObject> pipeline, final AggregationOptions options,
                            final ReadPreference readPreference) {
        Cursor cursor = aggregate(pipeline, options, readPreference, true);
        if (cursor == null) {
            throw new MongoInternalException("cursor can not be null in this context");
        }
        return cursor;
    }
public Cursor aggregate(final List<? extends DBObject> pipeline, final AggregationOptions options,
                            final ReadPreference readPreference) {
        Cursor cursor = aggregate(pipeline, options, readPreference, true);
        if (cursor == null) {
            throw new MongoInternalException("cursor can not be null in this context");
        }
        return cursor;
    }
Method implements aggregation framework.

@param pipeline       operations to be performed in the aggregation pipeline
@param options        options to apply to the aggregation
@param readPreference {@link ReadPreference} to be used for this operation
@return the aggregation operation's result set
@mongodb.driver.manual core/aggregation-pipeline/ Aggregation
@mongodb.server.release 2.2