Class MqlValues
MqlValue
, used primarily to
produce values in the context of the MongoDB Query Language (MQL).- Since:
- 4.9.0
-
Method Summary
Modifier and TypeMethodDescriptionstatic MqlDocument
current()
Returns a reference to the "current" document value.static <R extends MqlValue>
MqlMap<@MqlUnchecked(TYPE_ARGUMENT) R>Returns a reference to the "current" value as a map value.static MqlBoolean
of
(boolean of) Returns a boolean value corresponding to the providedboolean
primitive.static MqlNumber
of
(double of) Returns a number value corresponding to the provideddouble
primitive.static MqlInteger
of
(int of) Returns an integer value corresponding to the providedint
primitive.static MqlInteger
of
(long of) Returns an integer value corresponding to the providedlong
primitive.static MqlString
static MqlDate
Returns a date and time value corresponding to the providedInstant
.static MqlDocument
Returns a document value corresponding to the providedBson document
.static MqlNumber
of
(Decimal128 of) Returns a number value corresponding to the providedDecimal128
.ofArray
(T... array) static MqlArray<MqlBoolean>
ofBooleanArray
(boolean... array) ofDateArray
(Instant... array) Returns an entry value.static MqlArray<MqlInteger>
ofIntegerArray
(int... array) static MqlArray<MqlInteger>
ofIntegerArray
(long... array) ofMap()
Returns an empty map value.static <T extends MqlValue>
MqlMap<@MqlUnchecked(TYPE_ARGUMENT) T>Returns a map value corresponding to the providedBson document
.static MqlValue
ofNull()
The null value in the context of the MongoDB Query Language (MQL).ofNumberArray
(double... array) ofNumberArray
(Decimal128... array) ofStringArray
(String... array)
-
Method Details
-
of
Returns a boolean value corresponding to the providedboolean
primitive.- Parameters:
of
- theboolean
primitive.- Returns:
- the resulting value.
-
ofBooleanArray
- Parameters:
array
- the array.- Returns:
- the resulting value.
-
of
Returns an integer value corresponding to the providedint
primitive.- Parameters:
of
- theint
primitive.- Returns:
- the resulting value.
-
ofIntegerArray
- Parameters:
array
- the array.- Returns:
- the resulting value.
-
of
Returns an integer value corresponding to the providedlong
primitive.- Parameters:
of
- thelong
primitive.- Returns:
- the resulting value.
-
ofIntegerArray
- Parameters:
array
- the array.- Returns:
- the resulting value.
-
of
Returns a number value corresponding to the provideddouble
primitive.- Parameters:
of
- thedouble
primitive.- Returns:
- the resulting value.
-
ofNumberArray
- Parameters:
array
- the array.- Returns:
- the resulting value.
-
of
Returns a number value corresponding to the providedDecimal128
.- Parameters:
of
- theDecimal128
.- Returns:
- the resulting value.
-
ofNumberArray
- Parameters:
array
- the array.- Returns:
- the resulting value.
-
of
Returns a date and time value corresponding to the providedInstant
.- Parameters:
of
- theInstant
.- Returns:
- the resulting value.
-
ofDateArray
- Parameters:
array
- the array.- Returns:
- the resulting value.
-
of
- Parameters:
of
- theString
.- Returns:
- the resulting value.
-
ofStringArray
- Parameters:
array
- the array.- Returns:
- the resulting value.
-
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
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
- Type Parameters:
T
- the type of the array elements.- Parameters:
array
- the values.- Returns:
- the resulting value.
-
ofEntry
Returns an entry value.- Type Parameters:
T
- the type of the key.- Parameters:
k
- the key.v
- the value.- Returns:
- the resulting value.
-
ofMap
Returns an empty map value.- Type Parameters:
T
- the type of the resulting map's values.- Returns:
- the resulting map value.
-
ofMap
Returns a map value corresponding to the providedBson 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 aBson document
.- Returns:
- the resulting map value.
-
of
Returns a document value corresponding to the providedBson document
.- Parameters:
document
- the BSON document.- Returns:
- the resulting value.
-
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 useBranches.isNull(java.util.function.Function<? super com.mongodb.client.model.mql.MqlValue, ? extends R>)
withinMqlValue.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
-