Spring Data MongoDB - Core

org.springframework.data.mongodb.core.aggregation
Class Aggregation

java.lang.Object
  extended by org.springframework.data.mongodb.core.aggregation.Aggregation
Direct Known Subclasses:
TypedAggregation

public class Aggregation
extends Object

An Aggregation is a representation of a list of aggregation steps to be performed by the MongoDB Aggregation Framework.

Since:
1.3
Author:
Tobias Trelle, Thomas Darimont, Oliver Gierke

Field Summary
static AggregationOperationContext DEFAULT_CONTEXT
           
 
Constructor Summary
protected Aggregation(AggregationOperation... aggregationOperations)
          Creates a new Aggregation from the given AggregationOperations.
 
Method Summary
static Fields bind(String name, String target)
          Creates a new Fields instance from the given field name and target reference.
static Fields fields(String... fields)
          Creates a new Fields instance for the given field names.
static GroupOperation group(Fields fields)
          Creates a new GroupOperation for the given Fields.
static GroupOperation group(String... fields)
          Creates a new GroupOperation for the given fields.
static org.springframework.data.mongodb.core.aggregation.LimitOperation limit(long maxElements)
          Creates a new LimitOperation limiting the result to the given number of elements.
static MatchOperation match(Criteria criteria)
          Creates a new MatchOperation using the given Criteria.
static Aggregation newAggregation(AggregationOperation... operations)
          Creates a new Aggregation from the given AggregationOperations.
static
<T> TypedAggregation<T>
newAggregation(Class<T> type, AggregationOperation... operations)
          Creates a new TypedAggregation for the given type and AggregationOperations.
static String previousOperation()
          A pointer to the previous AggregationOperation.
static ProjectionOperation project(Fields fields)
          Creates a new ProjectionOperation includeing the given Fields.
static ProjectionOperation project(String... fields)
          Creates a new ProjectionOperation including the given fields.
static SkipOperation skip(int elementsToSkip)
          Creates a new SkipOperation skipping the given number of elements.
static SortOperation sort(Sort.Direction direction, String... fields)
          Factory method to create a new SortOperation for the given sort Sort.Direction and fields.
static SortOperation sort(Sort sort)
          Factory method to create a new SortOperation for the given Sort.
 com.mongodb.DBObject toDbObject(String inputCollectionName, AggregationOperationContext rootContext)
          Converts this Aggregation specification to a DBObject.
 String toString()
           
static UnwindOperation unwind(String field)
          Factory method to create a new UnwindOperation for the field with the given name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_CONTEXT

public static final AggregationOperationContext DEFAULT_CONTEXT
Constructor Detail

Aggregation

protected Aggregation(AggregationOperation... aggregationOperations)
Creates a new Aggregation from the given AggregationOperations.

Parameters:
aggregationOperations - must not be null or empty.
Method Detail

newAggregation

public static Aggregation newAggregation(AggregationOperation... operations)
Creates a new Aggregation from the given AggregationOperations.

Parameters:
operations - must not be null or empty.

newAggregation

public static <T> TypedAggregation<T> newAggregation(Class<T> type,
                                                     AggregationOperation... operations)
Creates a new TypedAggregation for the given type and AggregationOperations.

Parameters:
type - must not be null.
operations - must not be null or empty.

previousOperation

public static String previousOperation()
A pointer to the previous AggregationOperation.

Returns:

project

public static ProjectionOperation project(String... fields)
Creates a new ProjectionOperation including the given fields.

Parameters:
fields - must not be null.
Returns:

project

public static ProjectionOperation project(Fields fields)
Creates a new ProjectionOperation includeing the given Fields.

Parameters:
fields - must not be null.
Returns:

unwind

public static UnwindOperation unwind(String field)
Factory method to create a new UnwindOperation for the field with the given name.

Parameters:
fieldName - must not be null or empty.
Returns:

group

public static GroupOperation group(String... fields)
Creates a new GroupOperation for the given fields.

Parameters:
fields - must not be null.
Returns:

group

public static GroupOperation group(Fields fields)
Creates a new GroupOperation for the given Fields.

Parameters:
fields - must not be null.
Returns:

sort

public static SortOperation sort(Sort sort)
Factory method to create a new SortOperation for the given Sort.

Parameters:
sort - must not be null.
Returns:

sort

public static SortOperation sort(Sort.Direction direction,
                                 String... fields)
Factory method to create a new SortOperation for the given sort Sort.Direction and fields.

Parameters:
direction - must not be null.
fields - must not be null.
Returns:

skip

public static SkipOperation skip(int elementsToSkip)
Creates a new SkipOperation skipping the given number of elements.

Parameters:
elementsToSkip - must not be less than zero.
Returns:

limit

public static org.springframework.data.mongodb.core.aggregation.LimitOperation limit(long maxElements)
Creates a new LimitOperation limiting the result to the given number of elements.

Parameters:
maxElements - must not be less than zero.
Returns:

match

public static MatchOperation match(Criteria criteria)
Creates a new MatchOperation using the given Criteria.

Parameters:
criteria - must not be null.
Returns:

fields

public static Fields fields(String... fields)
Creates a new Fields instance for the given field names.

Parameters:
fields - must not be null.
Returns:
See Also:
Fields.fields(String...)

bind

public static Fields bind(String name,
                          String target)
Creates a new Fields instance from the given field name and target reference.

Parameters:
name - must not be null or empty.
target - must not be null or empty.
Returns:

toDbObject

public com.mongodb.DBObject toDbObject(String inputCollectionName,
                                       AggregationOperationContext rootContext)
Converts this Aggregation specification to a DBObject.

Parameters:
inputCollectionName - the name of the input collection
Returns:
the DBObject representing this aggregation

toString

public String toString()
Overrides:
toString in class Object

Spring Data MongoDB - Core

Copyright © 2011-2013-2013 Pivotal. All Rights Reserved.