Package com.mongodb.client.model
Class Windows
java.lang.Object
com.mongodb.client.model.Windows
Builders for windows used when expressing windowed computations.
There are two types of windows: documents and range.
Bounded and halfbounded windows require sorting. Window bounds are inclusive and the lower bound must always be less than or equal to the upper bound. The following typespecific rules are applied to windows:
 documents
 bounds
 0 refers to the current document and is functionally equivalent to
Windows.Bound.CURRENT
;  a negative value refers to documents preceding the current one;
 a positive value refers to documents following the current one;
 0 refers to the current document and is functionally equivalent to
 bounds
 range
sortBy
 bounds
 if numeric, i.e., not
Windows.Bound
, then the bound is calculated by adding the value to the value of thesortBy
field in the current document;  if
Windows.Bound.CURRENT
, then the bound is determined by the current document and not the current value of thesortBy
field;  time bounds require specifying a time unit and are added as per the
$dateAdd
/$dateSubtract
aggregation pipeline stage specification.
 if numeric, i.e., not
 Since:
 4.3
 See Also:
 MongoDB documentation
 $isNumber aggregation pipeline stage
 BSON Date type
 $dateAdd aggregation pipeline stage
 $dateSubtract aggregation pipeline stage
 Since server release
 5.0

Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
Special values that may be used when specifying the bounds of a window. 
Method Summary
Modifier and TypeMethodDescriptionstatic Window
documents
(int lower, int upper) Creates a documents window whose bounds are determined by a number of documents before and after the current document.static Window
documents
(int lower, Windows.Bound upper) Creates a documents window whose bounds are determined by a number of documents before and after the current document.static Window
documents
(Windows.Bound lower, int upper) Creates a documents window whose bounds are determined by a number of documents before and after the current document.static Window
documents
(Windows.Bound lower, Windows.Bound upper) Creates a documents window whose bounds are determined by a number of documents before and after the current document.static Window
Creates a window fromBson
in situations when there is no builder method that better satisfies your needs.static Window
range
(double lower, double upper) Creates a dynamicallysized range window whose bounds are determined by a range of possible values around the value of thesortBy
field in the current document.static Window
range
(double lower, Windows.Bound upper) Creates a dynamicallysized range window whose bounds are determined by a range of possible values around the value of thesortBy
field in the current document.static Window
range
(long lower, long upper) Creates a dynamicallysized range window whose bounds are determined by a range of possible values around the value of thesortBy
field in the current document.static Window
range
(long lower, Windows.Bound upper) Creates a dynamicallysized range window whose bounds are determined by a range of possible values around the value of thesortBy
field in the current document.static Window
range
(Windows.Bound lower, double upper) Creates a dynamicallysized range window whose bounds are determined by a range of possible values around the value of thesortBy
field in the current document.static Window
range
(Windows.Bound lower, long upper) Creates a dynamicallysized range window whose bounds are determined by a range of possible values around the value of thesortBy
field in the current document.static Window
range
(Windows.Bound lower, Decimal128 upper) Creates a dynamicallysized range window whose bounds are determined by a range of possible values around the value of thesortBy
field in the current document.static Window
range
(Decimal128 lower, Windows.Bound upper) Creates a dynamicallysized range window whose bounds are determined by a range of possible values around the value of thesortBy
field in the current document.static Window
range
(Decimal128 lower, Decimal128 upper) Creates a dynamicallysized range window whose bounds are determined by a range of possible values around the value of thesortBy
field in the current document.static Window
timeRange
(long lower, long upper, MongoTimeUnit unit) static Window
timeRange
(long lower, MongoTimeUnit unit, Windows.Bound upper) static Window
timeRange
(Windows.Bound lower, long upper, MongoTimeUnit unit)

Method Details

of
Creates a window fromBson
in situations when there is no builder method that better satisfies your needs. This method cannot be used to validate the syntax.Example
The following code creates two functionally equivalent windows, though they may not be equal.Window pastWeek1 = Windows.timeRange(1, MongoTimeUnit.WEEK, Windows.Bound.CURRENT); Window pastWeek2 = Windows.of( new Document("range", Arrays.asList(1, "current")) .append("unit", "week"));
 Parameters:
window
 ABson
representing the required window. Returns:
 The constructed window.

documents
Creates a documents window whose bounds are determined by a number of documents before and after the current document. Parameters:
lower
 A value based on which the lower bound of the window is calculated.upper
 A value based on which the upper bound of the window is calculated. Returns:
 The constructed documents window.

documents
Creates a documents window whose bounds are determined by a number of documents before and after the current document. Parameters:
lower
 A value based on which the lower bound of the window is calculated.upper
 A value based on which the upper bound of the window is calculated. Returns:
 The constructed documents window.

documents
Creates a documents window whose bounds are determined by a number of documents before and after the current document. Parameters:
lower
 A value based on which the lower bound of the window is calculated.upper
 A value based on which the upper bound of the window is calculated. Returns:
 The constructed documents window.

documents
Creates a documents window whose bounds are determined by a number of documents before and after the current document. Parameters:
lower
 A value based on which the lower bound of the window is calculated.upper
 A value based on which the upper bound of the window is calculated. Returns:
 The constructed documents window.

range
Creates a dynamicallysized range window whose bounds are determined by a range of possible values around the value of thesortBy
field in the current document. Parameters:
lower
 A value based on which the lower bound of the window is calculated.upper
 A value based on which the upper bound of the window is calculated. Returns:
 The constructed range window.

range
Creates a dynamicallysized range window whose bounds are determined by a range of possible values around the value of thesortBy
field in the current document. Parameters:
lower
 A value based on which the lower bound of the window is calculated.upper
 A value based on which the upper bound of the window is calculated. Returns:
 The constructed range window.

range
Creates a dynamicallysized range window whose bounds are determined by a range of possible values around the value of thesortBy
field in the current document. Parameters:
lower
 A value based on which the lower bound of the window is calculated.upper
 A value based on which the upper bound of the window is calculated. Returns:
 The constructed range window.

range
Creates a dynamicallysized range window whose bounds are determined by a range of possible values around the value of thesortBy
field in the current document. Parameters:
lower
 A value based on which the lower bound of the window is calculated.upper
 A value based on which the upper bound of the window is calculated. Returns:
 The constructed range window.

range
Creates a dynamicallysized range window whose bounds are determined by a range of possible values around the value of thesortBy
field in the current document. Parameters:
lower
 A value based on which the lower bound of the window is calculated.upper
 A value based on which the upper bound of the window is calculated. Returns:
 The constructed range window.

range
Creates a dynamicallysized range window whose bounds are determined by a range of possible values around the value of thesortBy
field in the current document. Parameters:
lower
 A value based on which the lower bound of the window is calculated.upper
 A value based on which the upper bound of the window is calculated. Returns:
 The constructed range window.

range
Creates a dynamicallysized range window whose bounds are determined by a range of possible values around the value of thesortBy
field in the current document. Parameters:
lower
 A value based on which the lower bound of the window is calculated.upper
 A value based on which the upper bound of the window is calculated. Returns:
 The constructed range window.

range
Creates a dynamicallysized range window whose bounds are determined by a range of possible values around the value of thesortBy
field in the current document. Parameters:
lower
 A value based on which the lower bound of the window is calculated.upper
 A value based on which the upper bound of the window is calculated. Returns:
 The constructed range window.

range
Creates a dynamicallysized range window whose bounds are determined by a range of possible values around the value of thesortBy
field in the current document. Parameters:
lower
 A value based on which the lower bound of the window is calculated.upper
 A value based on which the upper bound of the window is calculated. Returns:
 The constructed range window.

timeRange
Creates a dynamicallysized range window whose bounds are determined by a range of possible values around the BSONDate
value of thesortBy
field in the current document. Parameters:
lower
 A value based on which the lower bound of the window is calculated.upper
 A value based on which the upper bound of the window is calculated.unit
 A time unit in whichlower
andupper
are specified. Returns:
 The constructed range window.

timeRange
Creates a dynamicallysized range window whose bounds are determined by a range of possible values around the BSONDate
value of thesortBy
field in the current document. Parameters:
lower
 A value based on which the lower bound of the window is calculated.upper
 A value based on which the upper bound of the window is calculated.unit
 A time unit in whichupper
is specified. Returns:
 The constructed range window.

timeRange
Creates a dynamicallysized range window whose bounds are determined by a range of possible values around the BSONDate
value of thesortBy
field in the current document. Parameters:
lower
 A value based on which the lower bound of the window is calculated.unit
 A time unit in whichlower
is specified.upper
 A value based on which the upper bound of the window is calculated. Returns:
 The constructed range window.
