Class AggregationResults<T>

java.lang.Object
org.springframework.data.mongodb.core.aggregation.AggregationResults<T>
Type Parameters:
T - The class in which the results are mapped onto.
All Implemented Interfaces:
Iterable<T>

public class AggregationResults<T> extends Object implements Iterable<T>
Collects the results of executing an aggregation operation.
Since:
1.3
Author:
Tobias Trelle, Oliver Gierke, Thomas Darimont, Christoph Strobl, Mark Paluch
  • Constructor Details

    • AggregationResults

      public AggregationResults(List<T> mappedResults, org.bson.Document rawResults)
      Creates a new AggregationResults instance from the given mapped and raw results.
      Parameters:
      mappedResults - must not be null.
      rawResults - must not be null.
  • Method Details

    • getMappedResults

      public List<T> getMappedResults()
      Returns the aggregation results.
      Returns:
      the list of already mapped results or an empty one if none found.
    • getUniqueMappedResult

      @Nullable public T getUniqueMappedResult()
      Returns the unique mapped result. Assumes no result or exactly one.
      Returns:
      the single already mapped result object or raise an error if more than one found.
      Throws:
      IllegalArgumentException - in case more than one result is available.
    • iterator

      public Iterator<T> iterator()
      Specified by:
      iterator in interface Iterable<T>
    • getServerUsed

      @Nullable public String getServerUsed()
      Returns the server that has been used to perform the aggregation.
      Returns:
      can be null.
    • getRawResults

      public org.bson.Document getRawResults()
      Returns the raw result that was returned by the server.
      Returns:
      the raw response.
      Since:
      1.6