Interface MqlArray<T extends MqlValue>
- Type Parameters:
T
- the type of the elements
- All Superinterfaces:
MqlValue
value
in the context of the MongoDB Query
Language (MQL). An array is a finite, ordered collection of elements of a
certain type. It is also known as a finite mathematical sequence.- Since:
- 4.9.0
-
Method Summary
Modifier and TypeMethodDescriptionall
(Function<? super T, MqlBoolean> predicate) Whether all values inthis
array satisfy the predicate.any
(Function<? super T, MqlBoolean> predicate) Whether any value inthis
array satisfies the predicate.The result of concatenatingthis
array first with theother
array ensuing.concatArrays
(Function<? super T, ? extends MqlArray<? extends R>> mapper) distinct()
An array containing only the distinct values ofthis
array.default T
elementAt
(int i) Returns the element at the provided indexi
forthis
array.Returns the element at the provided indexi
forthis
array.filter
(Function<? super T, ? extends MqlBoolean> predicate) An array consisting of only those elements inthis
array that match the provided predicate.first()
Returns the first element ofthis
array.joinStrings
(Function<? super T, MqlString> mapper) The string-concatenation of all the values ofthis
array, via the providedmapper
.last()
Returns the last element ofthis
array.An array consisting of the results of applying the provided function to the elements ofthis
array.maxN
(MqlInteger n) minN
(MqlInteger n) The product of multiplying together all the values ofthis
array, via the providedmapper
.<R extends MqlValue>
RpassArrayTo
(Function<? super MqlArray<T>, ? extends R> f) The result of passingthis
value to the provided function.size()
The size ofthis
array.slice
(int start, int length) The subarray ofthis
array, from thestart
index inclusive, and continuing for the specifiedlength
, or to the end of the array.slice
(MqlInteger start, MqlInteger length) The subarray ofthis
array, from thestart
index inclusive, and continuing for the specifiedlength
, up to the end of the array.The sum of adding together all the values ofthis
array, via the providedmapper
.<R extends MqlValue>
RswitchArrayOn
(Function<Branches<MqlArray<T>>, ? extends BranchesTerminal<MqlArray<T>, ? extends R>> mapping) The result of applying the provided switch mapping tothis
value.The set-union ofthis
array and theother
array ensuing, containing only the distinct values of both.unionArrays
(Function<? super T, ? extends MqlArray<? extends R>> mapper) Methods inherited from interface com.mongodb.client.model.mql.MqlValue
asString, eq, equals, gt, gte, isArrayOr, isBooleanOr, isDateOr, isDocumentOr, isIntegerOr, isMapOr, isNumberOr, isStringOr, lt, lte, ne, passTo, switchOn
-
Method Details
-
filter
An array consisting of only those elements inthis
array that match the provided predicate.- Parameters:
predicate
- the predicate to apply to each element to determine if it should be included.- Returns:
- the resulting array.
-
map
An array consisting of the results of applying the provided function to the elements ofthis
array.- Type Parameters:
R
- the type of the elements of the resulting array.- Parameters:
in
- the function to apply to each element.- Returns:
- the resulting array.
-
size
MqlInteger size()The size ofthis
array.- Returns:
- the size.
-
any
Whether any value inthis
array satisfies the predicate.- Parameters:
predicate
- the predicate.- Returns:
- the resulting value.
-
all
Whether all values inthis
array satisfy the predicate.- Parameters:
predicate
- the predicate.- Returns:
- the resulting value.
-
sum
The sum of adding together all the values ofthis
array, via the providedmapper
. Returns 0 if the array is empty.The mapper may be used to transform the values of
this
array into numbers. If no transformation is necessary, then the identity functionarray.sum(v -> v)
should be used.- Parameters:
mapper
- the mapper function.- Returns:
- the resulting value.
-
multiply
The product of multiplying together all the values ofthis
array, via the providedmapper
. Returns 1 if the array is empty.The mapper may be used to transform the values of
this
array into numbers. If no transformation is necessary, then the identity functionarray.multiply(v -> v)
should be used.- Parameters:
mapper
- the mapper function.- Returns:
- the resulting value.
-
max
- Parameters:
other
- the other value.- Returns:
- the resulting value.
- Since server release
- 5.2
-
min
- Parameters:
other
- the other value.- Returns:
- the resulting value.
- Since server release
- 5.2
-
maxN
- Parameters:
n
- the number of elements.- Returns:
- the resulting value.
- Since server release
- 5.2
-
minN
- Parameters:
n
- the number of elements.- Returns:
- the resulting value.
- Since server release
- 5.2
-
joinStrings
The string-concatenation of all the values ofthis
array, via the providedmapper
. Returns the empty string if the array is empty.The mapper may be used to transform the values of
this
array into strings. If no transformation is necessary, then the identity functionarray.join(v -> v)
should be used.- Parameters:
mapper
- the mapper function.- Returns:
- the resulting value.
-
concatArrays
<R extends MqlValue> MqlArray<R> concatArrays(Function<? super T, ? extends MqlArray<? extends R>> mapper) The array-concatenation of all the array values ofthis
array, via the providedmapper
. Returns the empty array if the array is empty.The mapper may be used to transform the values of
this
array into arrays. If no transformation is necessary, then the identity functionarray.concat(v -> v)
should be used.- Type Parameters:
R
- the type of the elements of the array.- Parameters:
mapper
- the mapper function.- Returns:
- the resulting value.
-
unionArrays
<R extends MqlValue> MqlArray<R> unionArrays(Function<? super T, ? extends MqlArray<? extends R>> mapper) The set-union of all the array values ofthis
array, via the providedmapper
. Returns the empty array if the array is empty.The mapper may be used to transform the values of
this
array into arrays. If no transformation is necessary, then the identity functionarray.union(v -> v)
should be used.- Type Parameters:
R
- the type of the elements of the array.- Parameters:
mapper
- the mapper function.- Returns:
- the resulting value.
-
asMap
The map value corresponding to the entry values ofthis
array, via the providedmapper
. Returns the empty map if the array is empty.The mapper may be used to transform the values of
this
array into entries. If no transformation is necessary, then the identity functionarray.union(v -> v)
should be used.- Type Parameters:
R
- the type of the resulting map's values.- Parameters:
mapper
- the mapper function.- Returns:
- the resulting value.
- See Also:
-
elementAt
Returns the element at the provided indexi
forthis
array.Warning: The use of this method is an assertion that the index
i
is in bounds for the array. If the index is out of bounds for this array, then the behaviour of the API is not specified.- Parameters:
i
- the index.- Returns:
- the resulting value.
-
elementAt
Returns the element at the provided indexi
forthis
array.Warning: The use of this method is an assertion that the index
i
is in bounds for the array. If the index is out of bounds for this array, then the behaviour of the API is not specified.- Parameters:
i
- the index.- Returns:
- the resulting value.
-
first
Returns the first element ofthis
array.Warning: The use of this method is an assertion that the array is not empty. If the array is empty then the behaviour of the API is not specified.
- Returns:
- the resulting value.
- Since server release
- 4.4
-
last
Returns the last element ofthis
array.Warning: The use of this method is an assertion that the array is not empty. If the array is empty then the behaviour of the API is not specified.
- Returns:
- the resulting value.
- Since server release
- 4.4
-
contains
- Parameters:
value
- the value.- Returns:
- the resulting value.
-
concat
The result of concatenatingthis
array first with theother
array ensuing.- Parameters:
other
- the other array.- Returns:
- the resulting array.
-
slice
The subarray ofthis
array, from thestart
index inclusive, and continuing for the specifiedlength
, up to the end of the array.- Parameters:
start
- start indexlength
- length- Returns:
- the resulting value
-
slice
The subarray ofthis
array, from thestart
index inclusive, and continuing for the specifiedlength
, or to the end of the array.- Parameters:
start
- start indexlength
- length- Returns:
- the resulting value
-
union
The set-union ofthis
array and theother
array ensuing, containing only the distinct values of both. No guarantee is made regarding order.- Parameters:
other
- the other array.- Returns:
- the resulting array.
-
distinct
An array containing only the distinct values ofthis
array. No guarantee is made regarding order.- Returns:
- the resulting value
-
passArrayTo
The result of passingthis
value to the provided function. Equivalent tof.apply(this)
, and allows lambdas and static, user-defined functions to use the chaining syntax.- Type Parameters:
R
- the type of the resulting value.- Parameters:
f
- the function to apply.- Returns:
- the resulting value.
- See Also:
-
switchArrayOn
<R extends MqlValue> R switchArrayOn(Function<Branches<MqlArray<T>>, ? extends BranchesTerminal<MqlArray<T>, ? extends R>> mapping) The result of applying the provided switch mapping tothis
value.- Type Parameters:
R
- the type of the resulting value.- Parameters:
mapping
- the switch mapping.- Returns:
- the resulting value.
- See Also:
-