Spring Data MongoDB - Core

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

java.lang.Object
  extended by org.springframework.data.mongodb.core.aggregation.ProjectionOperation
All Implemented Interfaces:
AggregationOperation, FieldsExposingAggregationOperation

public class ProjectionOperation
extends Object
implements FieldsExposingAggregationOperation

Encapsulates the aggregation framework $project-operation. Projection of field to be used in an Aggregation. A projection is similar to a Field inclusion/exclusion but more powerful. It can generate new fields, change values of given field etc.

Since:
1.3
Author:
Tobias Trelle, Thomas Darimont, Oliver Gierke
See Also:
http://docs.mongodb.org/manual/reference/aggregation/project/

Nested Class Summary
static class ProjectionOperation.ProjectionOperationBuilder
          Builder for ProjectionOperations on a field.
 
Constructor Summary
ProjectionOperation()
          Creates a new empty ProjectionOperation.
ProjectionOperation(Fields fields)
          Creates a new ProjectionOperation including the given Fields.
 
Method Summary
 ProjectionOperation.ProjectionOperationBuilder and(String name)
          Creates a new ProjectionOperation.ProjectionOperationBuilder to define a projection for the field with the given name.
 ProjectionOperation andExclude(String... fieldNames)
          Excludes the given fields from the projection.
 ProjectionOperation andInclude(Fields fields)
          Includes the given fields into the projection.
 ProjectionOperation andInclude(String... fieldNames)
          Includes the given fields into the projection.
 ExposedFields getFields()
          Returns the fields exposed by the AggregationOperation.
 com.mongodb.DBObject toDBObject(AggregationOperationContext context)
          Turns the AggregationOperation into a DBObject by using the given AggregationOperationContext.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ProjectionOperation

public ProjectionOperation()
Creates a new empty ProjectionOperation.


ProjectionOperation

public ProjectionOperation(Fields fields)
Creates a new ProjectionOperation including the given Fields.

Parameters:
fields - must not be null.
Method Detail

and

public ProjectionOperation.ProjectionOperationBuilder and(String name)
Creates a new ProjectionOperation.ProjectionOperationBuilder to define a projection for the field with the given name.

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

andExclude

public ProjectionOperation andExclude(String... fieldNames)
Excludes the given fields from the projection.

Parameters:
fieldNames - must not be null.
Returns:

andInclude

public ProjectionOperation andInclude(String... fieldNames)
Includes the given fields into the projection.

Parameters:
fieldNames - must not be null.
Returns:

andInclude

public ProjectionOperation andInclude(Fields fields)
Includes the given fields into the projection.

Parameters:
fields - must not be null.
Returns:

getFields

public ExposedFields getFields()
Description copied from interface: FieldsExposingAggregationOperation
Returns the fields exposed by the AggregationOperation.

Specified by:
getFields in interface FieldsExposingAggregationOperation
Returns:
will never be null.

toDBObject

public com.mongodb.DBObject toDBObject(AggregationOperationContext context)
Description copied from interface: AggregationOperation
Turns the AggregationOperation into a DBObject by using the given AggregationOperationContext.

Specified by:
toDBObject in interface AggregationOperation
Returns:
the DBObject

Spring Data MongoDB - Core

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