Class AggregationPipeline

java.lang.Object
org.springframework.data.mongodb.core.aggregation.AggregationPipeline

public class AggregationPipeline extends Object
The AggregationPipeline holds the collection of aggregation stages.
Since:
3.0.2
Author:
Christoph Strobl, Mark Paluch
  • Constructor Details

    • AggregationPipeline

      public AggregationPipeline()
      Create an empty pipeline
    • AggregationPipeline

      public AggregationPipeline(List<AggregationOperation> aggregationOperations)
      Create a new pipeline with given stages.
      Parameters:
      aggregationOperations - must not be null.
  • Method Details

    • of

      public static AggregationPipeline of(AggregationOperation... stages)
    • add

      public AggregationPipeline add(AggregationOperation aggregationOperation)
      Append the given stage to the pipeline.
      Parameters:
      aggregationOperation - must not be null.
      Returns:
      this.
    • getOperations

      public List<AggregationOperation> getOperations()
      Get the list of aggregation stages.
      Returns:
      never null.
    • isOutOrMerge

      public boolean isOutOrMerge()
      Returns:
      true if the last aggregation stage is either $out or $merge.
    • containsUnionWith

      public boolean containsUnionWith()
      Return whether this aggregation pipeline defines a $unionWith stage that may contribute documents from other collections. Checking for presence of union stages is useful when attempting to determine the aggregation element type for mapping metadata computation.
      Returns:
      true the aggregation pipeline makes use of $unionWith.
      Since:
      3.1
    • isEmpty

      public boolean isEmpty()
      Returns:
      true if the pipeline does not contain any stages.
      Since:
      3.1