Class Branches<T extends MqlValue>

java.lang.Object
com.mongodb.client.model.mql.Branches<T>
Type Parameters:
T - the type of the values that may be checked.

@Beta(CLIENT) public final class Branches<T extends MqlValue> extends Object
Branches are used in 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>>), and define a sequence of checks that will be performed. The first check to succeed will produce the value that it specifies. If no check succeeds, then the operation defaults to a default value, or if none is specified, the operation will cause an error.
Since:
4.9.0
  • Method Details

    • is

      public <R extends MqlValue> BranchesIntermediary<T,R> is(Function<? super T,MqlBoolean> predicate, Function<? super T,? extends R> mapping)
      A successful check for the specified predicate produces a value specified by the mapping.
      Type Parameters:
      R - the type of the produced value.
      Parameters:
      predicate - the predicate.
      mapping - the mapping.
      Returns:
      the appended sequence of checks.
    • eq

      public <R extends MqlValue> BranchesIntermediary<T,R> eq(T v, Function<? super T,? extends R> mapping)
      A successful check for equality produces a value specified by the mapping.
      Type Parameters:
      R - the type of the produced value.
      Parameters:
      v - the value to check against.
      mapping - the mapping.
      Returns:
      the appended sequence of checks.
    • lt

      public <R extends MqlValue> BranchesIntermediary<T,R> lt(T v, Function<? super T,? extends R> mapping)
      A successful check for being less than the provided value v produces a value specified by the mapping.
      Type Parameters:
      R - the type of the produced value.
      Parameters:
      v - the value to check against.
      mapping - the mapping.
      Returns:
      the appended sequence of checks.
    • lte

      public <R extends MqlValue> BranchesIntermediary<T,R> lte(T v, Function<? super T,? extends R> mapping)
      A successful check for being less than or equal to the provided value v produces a value specified by the mapping.
      Type Parameters:
      R - the type of the produced value.
      Parameters:
      v - the value to check against.
      mapping - the mapping.
      Returns:
      the appended sequence of checks.
    • isBoolean

      public <R extends MqlValue> BranchesIntermediary<T,R> isBoolean(Function<? super MqlBoolean,? extends R> mapping)
      A successful check for being a boolean produces a value specified by the mapping.
      Type Parameters:
      R - the type of the produced value.
      Parameters:
      mapping - the mapping.
      Returns:
      the appended sequence of checks.
    • isNumber

      public <R extends MqlValue> BranchesIntermediary<T,R> isNumber(Function<? super MqlNumber,? extends R> mapping)
      A successful check for being a number produces a value specified by the mapping.
      Type Parameters:
      R - the type of the produced value.
      Parameters:
      mapping - the mapping.
      Returns:
      the appended sequence of checks.
      Since server release
      4.4
    • isInteger

      public <R extends MqlValue> BranchesIntermediary<T,R> isInteger(Function<? super MqlInteger,? extends R> mapping)
      A successful check for being an integer produces a value specified by the mapping.
      Type Parameters:
      R - the type of the produced value.
      Parameters:
      mapping - the mapping.
      Returns:
      the appended sequence of checks.
      Since server release
      4.4
    • isString

      public <R extends MqlValue> BranchesIntermediary<T,R> isString(Function<? super MqlString,? extends R> mapping)
      A successful check for being a string produces a value specified by the mapping.
      Type Parameters:
      R - the type of the produced value.
      Parameters:
      mapping - the mapping.
      Returns:
      the appended sequence of checks.
    • isDate

      public <R extends MqlValue> BranchesIntermediary<T,R> isDate(Function<? super MqlDate,? extends R> mapping)
      A successful check for being a date produces a value specified by the mapping.
      Type Parameters:
      R - the type of the produced value.
      Parameters:
      mapping - the mapping.
      Returns:
      the appended sequence of checks.
    • isArray

      public <R extends MqlValue, Q extends MqlValue> BranchesIntermediary<T,R> isArray(Function<? super MqlArray<@MqlUnchecked(TYPE_ARGUMENT) Q>,? extends R> mapping)
      A successful check for being an array produces a value specified by the mapping.

      Warning: The type argument of the array is not enforced by the API. The use of this method is an unchecked assertion that the type argument is correct.

      Type Parameters:
      R - the type of the produced value.
      Q - the type of the array.
      Parameters:
      mapping - the mapping.
      Returns:
      the appended sequence of checks.
    • isDocument

      public <R extends MqlValue> BranchesIntermediary<T,R> isDocument(Function<? super MqlDocument,? extends R> mapping)
      A successful check for being a document (or document-like value, see MqlMap and MqlEntry) produces a value specified by the mapping.
      Type Parameters:
      R - the type of the produced value.
      Parameters:
      mapping - the mapping.
      Returns:
      the appended sequence of checks.
    • isMap

      public <R extends MqlValue, Q extends MqlValue> BranchesIntermediary<T,R> isMap(Function<? super MqlMap<@MqlUnchecked(TYPE_ARGUMENT) Q>,? extends R> mapping)
      A successful check for being a map (or map-like value, see MqlDocument and MqlEntry) produces a value specified by the mapping.

      Warning: The type argument of the map is not enforced by the API. The use of this method is an unchecked assertion that the type argument is correct.

      Type Parameters:
      R - the type of the produced value.
      Q - the type of the array.
      Parameters:
      mapping - the mapping.
      Returns:
      the appended sequence of checks.
    • isNull

      public <R extends MqlValue> BranchesIntermediary<T,R> isNull(Function<? super MqlValue,? extends R> mapping)
      A successful check for MqlValues.ofNull() being the null value} produces a value specified by the mapping.
      Type Parameters:
      R - the type of the produced value.
      Parameters:
      mapping - the mapping.
      Returns:
      the appended sequence of checks.