Package dev.morphia.aggregation
Class Projection
- java.lang.Object
-
- dev.morphia.aggregation.Projection
-
public final class Projection extends java.lang.Object
Defines a projection for use in aggregation- MongoDB documentation
- reference/operator/aggregation/project/ $project
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Projection
add(java.lang.Object... args)
Creates an addition projectionstatic Projection
divide(java.lang.Object arg1, java.lang.Object arg2)
Creates a division projectionstatic Projection
expression(java.lang.String operator, java.lang.Object... args)
Provides access to arbitrary expressions taking an array of arguments, such as $concatjava.util.List<java.lang.Object>
getArguments()
java.util.List<Projection>
getProjections()
java.lang.String
getSource()
java.lang.String
getTarget()
boolean
isSuppressed()
static Projection
list(java.lang.Object... args)
Creates a list projectionstatic Projection
mod(java.lang.Object arg1, java.lang.Object arg2)
Creates a modulo projectionstatic Projection
multiply(java.lang.Object... args)
Creates a multiplication projectionstatic Projection
projection(java.lang.String field)
Creates a projection on a fieldstatic Projection
projection(java.lang.String field, Projection projection, Projection... subsequent)
Creates a projection on a field with subsequent projects applied.static Projection
projection(java.lang.String field, java.lang.String projectedField)
Creates a projection on a field and renames itstatic Projection
size(java.lang.Object expression)
Counts and returns the total the number of items in an arraystatic Projection
subtract(java.lang.Object arg1, java.lang.Object arg2)
Creates a subtraction projectionProjection
suppress()
Marks this field to be suppressed from the output of this stagejava.lang.String
toString()
-
-
-
Method Detail
-
projection
public static Projection projection(java.lang.String field)
Creates a projection on a field- Parameters:
field
- the field- Returns:
- the projection
-
projection
public static Projection projection(java.lang.String field, java.lang.String projectedField)
Creates a projection on a field and renames it- Parameters:
field
- the fieldprojectedField
- the new field name- Returns:
- the projection
-
projection
public static Projection projection(java.lang.String field, Projection projection, Projection... subsequent)
Creates a projection on a field with subsequent projects applied.- Parameters:
field
- the fieldprojection
- the project to applysubsequent
- the other projections to apply- Returns:
- the projection
-
expression
public static Projection expression(java.lang.String operator, java.lang.Object... args)
Provides access to arbitrary expressions taking an array of arguments, such as $concat- Parameters:
operator
- the operator for the projectionargs
- the projection arguments- Returns:
- the projection
-
list
public static Projection list(java.lang.Object... args)
Creates a list projection- Parameters:
args
- the projection arguments- Returns:
- the projection
-
add
public static Projection add(java.lang.Object... args)
Creates an addition projection- Parameters:
args
- the projection arguments- Returns:
- the projection
- MongoDB documentation
- reference/operator/aggregation/add $add
-
subtract
public static Projection subtract(java.lang.Object arg1, java.lang.Object arg2)
Creates a subtraction projection- Parameters:
arg1
- subtraction argumentarg2
- subtraction argument- Returns:
- the projection
- MongoDB documentation
- reference/operator/aggregation/subtract $subtract
-
multiply
public static Projection multiply(java.lang.Object... args)
Creates a multiplication projection- Parameters:
args
- the projection arguments- Returns:
- the projection
- MongoDB documentation
- reference/operator/aggregation/multiply $multiply
-
divide
public static Projection divide(java.lang.Object arg1, java.lang.Object arg2)
Creates a division projection- Parameters:
arg1
- subtraction argumentarg2
- subtraction argument- Returns:
- the projection
- MongoDB documentation
- reference/operator/aggregation/divide $divide
-
size
public static Projection size(java.lang.Object expression)
Counts and returns the total the number of items in an array- Parameters:
expression
- The argument for $size can be any expression as long as it resolves to an array.- Returns:
- the projection
- MongoDB documentation
- reference/operator/aggregation/size $size
-
mod
public static Projection mod(java.lang.Object arg1, java.lang.Object arg2)
Creates a modulo projection- Parameters:
arg1
- subtraction argumentarg2
- subtraction argument- Returns:
- the projection
- MongoDB documentation
- reference/operator/aggregation/mod $mod
-
getArguments
public java.util.List<java.lang.Object> getArguments()
- Returns:
- the arguments for the projection
-
getSource
public java.lang.String getSource()
- Returns:
- the projected field name
-
getProjections
public java.util.List<Projection> getProjections()
- Returns:
- any projections applied to this field
-
getTarget
public java.lang.String getTarget()
- Returns:
- the source field of the projection
-
isSuppressed
public boolean isSuppressed()
- Returns:
- true if this field is suppressed from the output
-
suppress
public Projection suppress()
Marks this field to be suppressed from the output of this stage- Returns:
- this
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-