Module spring.data.mongodb
Class ArrayOperators.ArrayOperatorFactory
java.lang.Object
org.springframework.data.mongodb.core.aggregation.ArrayOperators.ArrayOperatorFactory
- Enclosing class:
- ArrayOperators
- Author:
- Christoph Strobl
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface -
Constructor Summary
ConstructorsConstructorDescriptionArrayOperatorFactory(String fieldReference) Creates newArrayOperators.ArrayOperatorFactoryfor given fieldReference.ArrayOperatorFactory(Collection<?> values) Creates newArrayOperators.ArrayOperatorFactoryfor given values.ArrayOperatorFactory(AggregationExpression expression) Creates newArrayOperators.ArrayOperatorFactoryfor givenAggregationExpression. -
Method Summary
Modifier and TypeMethodDescriptionCreates newAggregationExpressionthat takes the associated array and concats the given arrayFieldReference to it.concat(AggregationExpression expression) Creates newAggregationExpressionthat takes the associated array and concats the array resulting form the given expression to it.containsValue(Object value) Creates newAggregationExpressionthat returns a boolean indicating whether a specified value is in the associated array.elementAt(int position) Creates newAggregationExpressionthat takes the associated array and returns the element at the specified array position.Creates newAggregationExpressionthat takes the associated array and returns the element at the position defined by the referenced field.elementAt(AggregationExpression expression) Creates newAggregationExpressionthat takes the associated array and returns the element at the position resulting form the given expression.filter()Creates newAggregationExpressionthat takes the associated array and selects a subset of the array to return based on the specified condition.first()Creates newAggregationExpressionthat return the first element in the associated array.Creates newAggregationExpressionthat searches the associated array for an occurrence of a specified value and returns the array index (zero-based) of the first occurrence.isArray()Creates newAggregationExpressionthat takes the associated array and an check if its an array.last()Creates newAggregationExpressionthat return the last element in the given array.length()Creates newAggregationExpressionthat takes the associated array and retrieves its length.reduce(AggregationExpression expression) Start creating newAggregationExpressionthat applies anAggregationExpressionto each element in an array and combines them into a single value.reduce(ArrayOperators.Reduce.PropertyExpression... expressions) Start creating newAggregationExpressionthat applies anAggregationExpressionto each element in an array and combines them into a single value.reverse()Creates newAggregationExpressionthat returns an array with the elements in reverse order.slice()Creates newAggregationExpressionthat takes the associated array and selects a subset from it.Creates newAggregationExpressionthat takes the associated array and sorts it by the givenorder.toObject()Creates newAggregationExpressionthat converts the associated expression into an object.Creates newAggregationExpressionthat transposes an array of input arrays so that the first element of the output array would be an array containing, the first element of the first input array, the first element of the second input array, etc.
-
Constructor Details
-
ArrayOperatorFactory
Creates newArrayOperators.ArrayOperatorFactoryfor given fieldReference.- Parameters:
fieldReference- must not be null.
-
ArrayOperatorFactory
Creates newArrayOperators.ArrayOperatorFactoryfor givenAggregationExpression.- Parameters:
expression- must not be null.
-
ArrayOperatorFactory
Creates newArrayOperators.ArrayOperatorFactoryfor given values.- Parameters:
values- must not be null.- Since:
- 2.2
-
-
Method Details
-
elementAt
Creates newAggregationExpressionthat takes the associated array and returns the element at the specified array position.- Parameters:
position- the element index.- Returns:
- new instance of
ArrayOperators.ArrayElemAt.
-
elementAt
Creates newAggregationExpressionthat takes the associated array and returns the element at the position resulting form the given expression.- Parameters:
expression- must not be null.- Returns:
- new instance of
ArrayOperators.ArrayElemAt.
-
elementAt
Creates newAggregationExpressionthat takes the associated array and returns the element at the position defined by the referenced field.- Parameters:
fieldReference- must not be null.- Returns:
- new instance of
ArrayOperators.ArrayElemAt.
-
concat
Creates newAggregationExpressionthat takes the associated array and concats the given arrayFieldReference to it.- Parameters:
arrayFieldReference- must not be null.- Returns:
- new instance of
ArrayOperators.ConcatArrays.
-
concat
Creates newAggregationExpressionthat takes the associated array and concats the array resulting form the given expression to it.- Parameters:
expression- must not be null.- Returns:
- new instance of
ArrayOperators.ConcatArrays.
-
filter
Creates newAggregationExpressionthat takes the associated array and selects a subset of the array to return based on the specified condition.- Returns:
- new instance of
ArrayOperators.Filter.AsBuilderto create aArrayOperators.Filter.
-
isArray
Creates newAggregationExpressionthat takes the associated array and an check if its an array.- Returns:
- new instance of
ArrayOperators.IsArray.
-
length
Creates newAggregationExpressionthat takes the associated array and retrieves its length.- Returns:
- new instance of
ArrayOperators.Size.
-
slice
Creates newAggregationExpressionthat takes the associated array and selects a subset from it.- Returns:
- new instance of
ArrayOperators.Slice.
-
indexOf
Creates newAggregationExpressionthat searches the associated array for an occurrence of a specified value and returns the array index (zero-based) of the first occurrence.- Parameters:
value- must not be null.- Returns:
- new instance of
ArrayOperators.IndexOfArray.
-
reverse
Creates newAggregationExpressionthat returns an array with the elements in reverse order.- Returns:
- new instance of
ArrayOperators.ReverseArray.
-
reduce
public ArrayOperators.ArrayOperatorFactory.ReduceInitialValueBuilder reduce(AggregationExpression expression) Start creating newAggregationExpressionthat applies anAggregationExpressionto each element in an array and combines them into a single value.- Parameters:
expression- must not be null.- Returns:
- new instance of
ArrayOperators.ArrayOperatorFactory.ReduceInitialValueBuilderto createArrayOperators.Reduce.
-
reduce
public ArrayOperators.ArrayOperatorFactory.ReduceInitialValueBuilder reduce(ArrayOperators.Reduce.PropertyExpression... expressions) Start creating newAggregationExpressionthat applies anAggregationExpressionto each element in an array and combines them into a single value.- Parameters:
expressions- must not be null.- Returns:
- new instance of
ArrayOperators.ArrayOperatorFactory.ReduceInitialValueBuilderto createArrayOperators.Reduce.
-
sort
Creates newAggregationExpressionthat takes the associated array and sorts it by the givenorder.- Returns:
- new instance of
ArrayOperators.SortArray. - Since:
- 4.0
-
zipWith
Creates newAggregationExpressionthat transposes an array of input arrays so that the first element of the output array would be an array containing, the first element of the first input array, the first element of the second input array, etc.- Parameters:
arrays- must not be null.- Returns:
- new instance of
ArrayOperators.Zip.
-
containsValue
Creates newAggregationExpressionthat returns a boolean indicating whether a specified value is in the associated array.- Parameters:
value- must not be null.- Returns:
- new instance of
ArrayOperators.In.
-
toObject
Creates newAggregationExpressionthat converts the associated expression into an object. NOTE: Requires MongoDB 3.6 or later.- Returns:
- new instance of
ArrayOperators.ArrayToObject. - Since:
- 2.1
-
first
Creates newAggregationExpressionthat return the first element in the associated array. NOTE: Requires MongoDB 4.4 or later.- Returns:
- new instance of
ArrayOperators.First. - Since:
- 3.4
-
last
Creates newAggregationExpressionthat return the last element in the given array. NOTE: Requires MongoDB 4.4 or later.- Returns:
- new instance of
ArrayOperators.Last. - Since:
- 3.4
-