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 inthisarray satisfy the predicate.any(Function<? super T, MqlBoolean> predicate) Whether any value inthisarray satisfies the predicate.The result of concatenatingthisarray first with theotherarray ensuing.concatArrays(Function<? super T, ? extends MqlArray<? extends R>> mapper) distinct()An array containing only the distinct values ofthisarray.default TelementAt(int i) Returns the element at the provided indexiforthisarray.Returns the element at the provided indexiforthisarray.filter(Function<? super T, ? extends MqlBoolean> predicate) An array consisting of only those elements inthisarray that match the provided predicate.first()Returns the first element ofthisarray.joinStrings(Function<? super T, MqlString> mapper) The string-concatenation of all the values ofthisarray, via the providedmapper.last()Returns the last element ofthisarray.An array consisting of the results of applying the provided function to the elements ofthisarray.maxN(MqlInteger n) minN(MqlInteger n) The product of multiplying together all the values ofthisarray, via the providedmapper.<R extends MqlValue>
RpassArrayTo(Function<? super MqlArray<T>, ? extends R> f) The result of passingthisvalue to the provided function.size()The size ofthisarray.slice(int start, int length) The subarray ofthisarray, from thestartindex inclusive, and continuing for the specifiedlength, or to the end of the array.slice(MqlInteger start, MqlInteger length) The subarray ofthisarray, from thestartindex inclusive, and continuing for the specifiedlength, up to the end of the array.The sum of adding together all the values ofthisarray, 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 tothisvalue.The set-union ofthisarray and theotherarray 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 inthisarray 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 ofthisarray.- 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 ofthisarray.- Returns:
- the size.
-
any
Whether any value inthisarray satisfies the predicate.- Parameters:
predicate- the predicate.- Returns:
- the resulting value.
-
all
Whether all values inthisarray satisfy the predicate.- Parameters:
predicate- the predicate.- Returns:
- the resulting value.
-
sum
The sum of adding together all the values ofthisarray, via the providedmapper. Returns 0 if the array is empty.The mapper may be used to transform the values of
thisarray 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 ofthisarray, via the providedmapper. Returns 1 if the array is empty.The mapper may be used to transform the values of
thisarray 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 ofthisarray, via the providedmapper. Returns the empty string if the array is empty.The mapper may be used to transform the values of
thisarray 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 ofthisarray, via the providedmapper. Returns the empty array if the array is empty.The mapper may be used to transform the values of
thisarray 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 ofthisarray, via the providedmapper. Returns the empty array if the array is empty.The mapper may be used to transform the values of
thisarray 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 ofthisarray, via the providedmapper. Returns the empty map if the array is empty.The mapper may be used to transform the values of
thisarray 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 indexiforthisarray.Warning: The use of this method is an assertion that the index
iis 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 indexiforthisarray.Warning: The use of this method is an assertion that the index
iis 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 ofthisarray.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 ofthisarray.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 concatenatingthisarray first with theotherarray ensuing.- Parameters:
other- the other array.- Returns:
- the resulting array.
-
slice
The subarray ofthisarray, from thestartindex 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 ofthisarray, from thestartindex 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 ofthisarray and theotherarray 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 ofthisarray. No guarantee is made regarding order.- Returns:
- the resulting value
-
passArrayTo
The result of passingthisvalue 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 tothisvalue.- Type Parameters:
R- the type of the resulting value.- Parameters:
mapping- the switch mapping.- Returns:
- the resulting value.
- See Also:
-