Interface MqlArray<T extends MqlValue>

Type Parameters:
T - the type of the elements
All Superinterfaces:
MqlValue

@Sealed @Beta(CLIENT) public interface MqlArray<T extends MqlValue> extends MqlValue
An array 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 Details

    • filter

      MqlArray<T> filter(Function<? super T,? extends MqlBoolean> predicate)
      An array consisting of only those elements in this 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

      <R extends MqlValue> MqlArray<R> map(Function<? super T,? extends R> in)
      An array consisting of the results of applying the provided function to the elements of this 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 of this array.
      Returns:
      the size.
    • any

      MqlBoolean any(Function<? super T,MqlBoolean> predicate)
      Whether any value in this array satisfies the predicate.
      Parameters:
      predicate - the predicate.
      Returns:
      the resulting value.
    • all

      MqlBoolean all(Function<? super T,MqlBoolean> predicate)
      Whether all values in this array satisfy the predicate.
      Parameters:
      predicate - the predicate.
      Returns:
      the resulting value.
    • sum

      MqlNumber sum(Function<? super T,? extends MqlNumber> mapper)
      The sum of adding together all the values of this array, via the provided mapper. 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 function array.sum(v -> v) should be used.

      Parameters:
      mapper - the mapper function.
      Returns:
      the resulting value.
    • multiply

      MqlNumber multiply(Function<? super T,? extends MqlNumber> mapper)
      The product of multiplying together all the values of this array, via the provided mapper. 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 function array.multiply(v -> v) should be used.

      Parameters:
      mapper - the mapper function.
      Returns:
      the resulting value.
    • max

      T max(T other)
      The largest value all the values of this array, or the other value if this array is empty.
      Parameters:
      other - the other value.
      Returns:
      the resulting value.
      Since server release
      5.2
    • min

      T min(T other)
      The smallest value all the values of this array, or the other value if this array is empty.
      Parameters:
      other - the other value.
      Returns:
      the resulting value.
      Since server release
      5.2
    • maxN

      MqlArray<T> maxN(MqlInteger n)
      The largest n elements of this array, or all elements if the array contains fewer than n elements.
      Parameters:
      n - the number of elements.
      Returns:
      the resulting value.
      Since server release
      5.2
    • minN

      MqlArray<T> minN(MqlInteger n)
      The smallest n elements of this array, or all elements if the array contains fewer than n elements.
      Parameters:
      n - the number of elements.
      Returns:
      the resulting value.
      Since server release
      5.2
    • joinStrings

      MqlString joinStrings(Function<? super T,MqlString> mapper)
      The string-concatenation of all the values of this array, via the provided mapper. 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 function array.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 of this array, via the provided mapper. 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 function array.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 of this array, via the provided mapper. 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 function array.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

      <R extends MqlValue> MqlMap<R> asMap(Function<? super T,? extends MqlEntry<? extends R>> mapper)
      The map value corresponding to the entry values of this array, via the provided mapper. 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 function array.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 index i for this 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

      @MqlUnchecked(PRESENT) default T elementAt(int i)
      Returns the element at the provided index i for this 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 of this 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 of this 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

      MqlBoolean contains(T value)
      Whether this array contains a value that is equal to the provided value.
      Parameters:
      value - the value.
      Returns:
      the resulting value.
    • concat

      MqlArray<T> concat(MqlArray<? extends T> other)
      The result of concatenating this array first with the other array ensuing.
      Parameters:
      other - the other array.
      Returns:
      the resulting array.
    • slice

      MqlArray<T> slice(MqlInteger start, MqlInteger length)
      The subarray of this array, from the start index inclusive, and continuing for the specified length, up to the end of the array.
      Parameters:
      start - start index
      length - length
      Returns:
      the resulting value
    • slice

      default MqlArray<T> slice(int start, int length)
      The subarray of this array, from the start index inclusive, and continuing for the specified length, or to the end of the array.
      Parameters:
      start - start index
      length - length
      Returns:
      the resulting value
    • union

      MqlArray<T> union(MqlArray<? extends T> other)
      The set-union of this array and the other 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

      MqlArray<T> distinct()
      An array containing only the distinct values of this array. No guarantee is made regarding order.
      Returns:
      the resulting value
    • passArrayTo

      <R extends MqlValue> R passArrayTo(Function<? super MqlArray<T>,? extends R> f)
      The result of passing this value to the provided function. Equivalent to f.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 to this value.
      Type Parameters:
      R - the type of the resulting value.
      Parameters:
      mapping - the switch mapping.
      Returns:
      the resulting value.
      See Also: