Class MqlValues

java.lang.Object
com.mongodb.client.model.mql.MqlValues

@Beta(CLIENT) public final class MqlValues extends Object
Convenience methods related to MqlValue, used primarily to produce values in the context of the MongoDB Query Language (MQL).
Since:
4.9.0
  • Method Details

    • of

      public static MqlBoolean of(boolean of)
      Returns a boolean value corresponding to the provided boolean primitive.
      Parameters:
      of - the boolean primitive.
      Returns:
      the resulting value.
    • ofBooleanArray

      public static MqlArray<MqlBoolean> ofBooleanArray(boolean... array)
      Returns an array of booleans corresponding to the provided boolean primitives.
      Parameters:
      array - the array.
      Returns:
      the resulting value.
    • of

      public static MqlInteger of(int of)
      Returns an integer value corresponding to the provided int primitive.
      Parameters:
      of - the int primitive.
      Returns:
      the resulting value.
    • ofIntegerArray

      public static MqlArray<MqlInteger> ofIntegerArray(int... array)
      Returns an array of integers corresponding to the provided int primitives.
      Parameters:
      array - the array.
      Returns:
      the resulting value.
    • of

      public static MqlInteger of(long of)
      Returns an integer value corresponding to the provided long primitive.
      Parameters:
      of - the long primitive.
      Returns:
      the resulting value.
    • ofIntegerArray

      public static MqlArray<MqlInteger> ofIntegerArray(long... array)
      Returns an array of integers corresponding to the provided long primitives.
      Parameters:
      array - the array.
      Returns:
      the resulting value.
    • of

      public static MqlNumber of(double of)
      Returns a number value corresponding to the provided double primitive.
      Parameters:
      of - the double primitive.
      Returns:
      the resulting value.
    • ofNumberArray

      public static MqlArray<MqlNumber> ofNumberArray(double... array)
      Returns an array of numbers corresponding to the provided double primitives.
      Parameters:
      array - the array.
      Returns:
      the resulting value.
    • of

      public static MqlNumber of(Decimal128 of)
      Returns a number value corresponding to the provided Decimal128.
      Parameters:
      of - the Decimal128.
      Returns:
      the resulting value.
    • ofNumberArray

      public static MqlArray<MqlNumber> ofNumberArray(Decimal128... array)
      Returns an array of numbers corresponding to the provided Decimal128s.
      Parameters:
      array - the array.
      Returns:
      the resulting value.
    • of

      public static MqlDate of(Instant of)
      Returns a date and time value corresponding to the provided Instant.
      Parameters:
      of - the Instant.
      Returns:
      the resulting value.
    • ofDateArray

      public static MqlArray<MqlDate> ofDateArray(Instant... array)
      Returns an array of dates corresponding to the provided Instants.
      Parameters:
      array - the array.
      Returns:
      the resulting value.
    • of

      public static MqlString of(String of)
      Returns an string value corresponding to the provided String.
      Parameters:
      of - the String.
      Returns:
      the resulting value.
    • ofStringArray

      public static MqlArray<MqlString> ofStringArray(String... array)
      Returns an array of strings corresponding to the provided Strings.
      Parameters:
      array - the array.
      Returns:
      the resulting value.
    • current

      public static MqlDocument current()
      Returns a reference to the "current" document value. The "current" value is the top-level document currently being processed in the aggregation pipeline stage.
      Returns:
      a reference to the current value
    • currentAsMap

      public static <R extends MqlValue> MqlMap<@MqlUnchecked(TYPE_ARGUMENT) R> currentAsMap()
      Returns a reference to the "current" value as a map value. The "current" value is the top-level document currently being processed in the aggregation pipeline stage.

      Warning: The type of the values of the resulting map are not enforced by the API. The specification of a type by the user is an unchecked assertion that all map values are of that type. If the map contains multiple types (such as both nulls and integers) then a super-type encompassing all types must be chosen, and if necessary the elements should be individually type-checked when used.

      Type Parameters:
      R - the type of the map's values.
      Returns:
      a reference to the current value as a map.
    • ofArray

      @SafeVarargs public static <T extends MqlValue> MqlArray<T> ofArray(T... array)
      Returns an array value, containing the values provided.
      Type Parameters:
      T - the type of the array elements.
      Parameters:
      array - the values.
      Returns:
      the resulting value.
    • ofEntry

      public static <T extends MqlValue> MqlEntry<T> ofEntry(MqlString k, T v)
      Returns an entry value.
      Type Parameters:
      T - the type of the key.
      Parameters:
      k - the key.
      v - the value.
      Returns:
      the resulting value.
    • ofMap

      public static <T extends MqlValue> MqlMap<T> ofMap()
      Returns an empty map value.
      Type Parameters:
      T - the type of the resulting map's values.
      Returns:
      the resulting map value.
    • ofMap

      public static <T extends MqlValue> MqlMap<@MqlUnchecked(TYPE_ARGUMENT) T> ofMap(Bson map)
      Returns a map value corresponding to the provided Bson document.

      Warning: The type of the values of the resulting map are not enforced by the API. The specification of a type by the user is an unchecked assertion that all map values are of that type. If the map contains multiple types (such as both nulls and integers) then a super-type encompassing all types must be chosen, and if necessary the elements should be individually type-checked when used.

      Type Parameters:
      T - the type of the resulting map's values.
      Parameters:
      map - the map as a Bson document.
      Returns:
      the resulting map value.
    • of

      public static MqlDocument of(Bson document)
      Returns a document value corresponding to the provided Bson document.
      Parameters:
      document - the BSON document.
      Returns:
      the resulting value.
    • ofNull

      public static MqlValue ofNull()
      The null value in the context of the MongoDB Query Language (MQL).

      The null value is not part of, and cannot be used as if it were part of, any explicit type (except the root type MqlValue itself). It has no explicit type of its own.

      Instead of checking that a value is null, users should generally check that a value is of their expected type, via methods such as MqlValue.isNumberOr(MqlNumber). Where the null value must be checked explicitly, users may use Branches.isNull(java.util.function.Function<? super com.mongodb.client.model.mql.MqlValue, ? extends R>) within MqlValue.switchOn(java.util.function.Function<com.mongodb.client.model.mql.Branches<com.mongodb.client.model.mql.MqlValue>, ? extends com.mongodb.client.model.mql.BranchesTerminal<com.mongodb.client.model.mql.MqlValue, ? extends R>>).

      Returns:
      the null value