Spring Data MongoDB - Core

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

java.lang.Object
  extended by org.springframework.data.mongodb.core.aggregation.ProjectionOperation.ProjectionOperationBuilder
All Implemented Interfaces:
AggregationOperation
Enclosing class:
ProjectionOperation

public static class ProjectionOperation.ProjectionOperationBuilder
extends Object
implements AggregationOperation

Builder for ProjectionOperations on a field.

Author:
Oliver Gierke

Constructor Summary
ProjectionOperation.ProjectionOperationBuilder(String name, ProjectionOperation operation, org.springframework.data.mongodb.core.aggregation.ProjectionOperation.ProjectionOperationBuilder.OperationProjection previousProjection)
          Creates a new ProjectionOperation.ProjectionOperationBuilder for the field with the given name on top of the given ProjectionOperation.
 
Method Summary
 ProjectionOperation as(String alias)
          Allows to specify an alias for the previous projection operation.
 ProjectionOperation.ProjectionOperationBuilder divide(Number number)
          Generates an $divide expression that divides the previously mentioned field by the given number.
 ProjectionOperation.ProjectionOperationBuilder minus(Number number)
          Generates an $subtract expression that subtracts the given number to the previously mentioned field.
 ProjectionOperation.ProjectionOperationBuilder mod(Number number)
          Generates an $mod expression that divides the previously mentioned field by the given number and returns the remainder.
 ProjectionOperation.ProjectionOperationBuilder multiply(Number number)
          Generates an $multiply expression that multiplies the given number with the previously mentioned field.
 ProjectionOperation nested(Fields fields)
          Defines a nested field binding for the current field.
 ProjectionOperation.ProjectionOperationBuilder plus(Number number)
          Generates an $add expression that adds the given number to the previously mentioned field.
 ProjectionOperation previousOperation()
          Projects the result of the previous operation onto the current field.
 ProjectionOperation.ProjectionOperationBuilder project(String operation, Object... values)
          Adds a generic projection for the current field.
 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.ProjectionOperationBuilder

public ProjectionOperation.ProjectionOperationBuilder(String name,
                                                      ProjectionOperation operation,
                                                      org.springframework.data.mongodb.core.aggregation.ProjectionOperation.ProjectionOperationBuilder.OperationProjection previousProjection)
Creates a new ProjectionOperation.ProjectionOperationBuilder for the field with the given name on top of the given ProjectionOperation.

Parameters:
name - must not be null or empty.
operation - must not be null.
previousProjection - the previous operation projection, may be null.
Method Detail

previousOperation

public ProjectionOperation previousOperation()
Projects the result of the previous operation onto the current field. Will automatically add an exclusion for _id as what would be held in it by default will now go into the field just projected into.

Returns:

nested

public ProjectionOperation nested(Fields fields)
Defines a nested field binding for the current field.

Parameters:
fields - must not be null.
Returns:

as

public ProjectionOperation as(String alias)
Allows to specify an alias for the previous projection operation.

Parameters:
string -
Returns:

plus

public ProjectionOperation.ProjectionOperationBuilder plus(Number number)
Generates an $add expression that adds the given number to the previously mentioned field.

Parameters:
number -
Returns:

minus

public ProjectionOperation.ProjectionOperationBuilder minus(Number number)
Generates an $subtract expression that subtracts the given number to the previously mentioned field.

Parameters:
number -
Returns:

multiply

public ProjectionOperation.ProjectionOperationBuilder multiply(Number number)
Generates an $multiply expression that multiplies the given number with the previously mentioned field.

Parameters:
number -
Returns:

divide

public ProjectionOperation.ProjectionOperationBuilder divide(Number number)
Generates an $divide expression that divides the previously mentioned field by the given number.

Parameters:
number -
Returns:

mod

public ProjectionOperation.ProjectionOperationBuilder mod(Number number)
Generates an $mod expression that divides the previously mentioned field by the given number and returns the remainder.

Parameters:
number -
Returns:

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

project

public ProjectionOperation.ProjectionOperationBuilder project(String operation,
                                                              Object... values)
Adds a generic projection for the current field.

Parameters:
operation - the operation key, e.g. $add.
values - the values to be set for the projection operation.
Returns:

Spring Data MongoDB - Core

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