14
14
* limitations under the License.
15
15
*/
16
16
17
- package com .mongodb .client .model .expressions ;
17
+ package com .mongodb .client .model .mql ;
18
18
19
19
import com .mongodb .annotations .Beta ;
20
20
import com .mongodb .assertions .Assertions ;
23
23
import java .util .List ;
24
24
import java .util .function .Function ;
25
25
26
- import static com .mongodb .client .model .expressions .MqlUnchecked .Unchecked .TYPE_ARGUMENT ;
26
+ import static com .mongodb .client .model .mql .MqlUnchecked .Unchecked .TYPE_ARGUMENT ;
27
27
28
28
/**
29
- * Branches are used in {@linkplain Expression #switchOn}, and
29
+ * Branches are used in {@linkplain MqlValue #switchOn}, and
30
30
* define a sequence of checks that will be performed. The first check
31
31
* to succeed will produce the value that it specifies. If no check succeeds,
32
32
* then the operation
37
37
* @since 4.9.0
38
38
*/
39
39
@ Beta (Beta .Reason .CLIENT )
40
- public final class Branches <T extends Expression > {
40
+ public final class Branches <T extends MqlValue > {
41
41
42
42
Branches () {
43
43
}
44
44
45
- private static <T extends Expression , R extends Expression > BranchesIntermediary <T , R > with (final Function <T , SwitchCase <R >> switchCase ) {
45
+ private static <T extends MqlValue , R extends MqlValue > BranchesIntermediary <T , R > with (final Function <T , SwitchCase <R >> switchCase ) {
46
46
List <Function <T , SwitchCase <R >>> v = new ArrayList <>();
47
47
v .add (switchCase );
48
48
return new BranchesIntermediary <>(v );
49
49
}
50
50
51
- private static <T extends Expression > MqlExpression <?> mqlEx (final T value ) {
51
+ private static <T extends MqlValue > MqlExpression <?> mqlEx (final T value ) {
52
52
return (MqlExpression <?>) value ;
53
53
}
54
54
@@ -63,7 +63,7 @@ private static <T extends Expression> MqlExpression<?> mqlEx(final T value) {
63
63
* @param <R> the type of the produced value.
64
64
* @return the appended sequence of checks.
65
65
*/
66
- public <R extends Expression > BranchesIntermediary <T , R > is (final Function <? super T , BooleanExpression > predicate , final Function <? super T , ? extends R > mapping ) {
66
+ public <R extends MqlValue > BranchesIntermediary <T , R > is (final Function <? super T , MqlBoolean > predicate , final Function <? super T , ? extends R > mapping ) {
67
67
Assertions .notNull ("predicate" , predicate );
68
68
Assertions .notNull ("mapping" , mapping );
69
69
return with (value -> new SwitchCase <>(predicate .apply (value ), mapping .apply (value )));
@@ -72,23 +72,23 @@ public <R extends Expression> BranchesIntermediary<T, R> is(final Function<? sup
72
72
// eq lt lte
73
73
74
74
/**
75
- * A successful check for {@linkplain Expression #eq equality}
75
+ * A successful check for {@linkplain MqlValue #eq equality}
76
76
* produces a value specified by the {@code mapping}.
77
77
*
78
78
* @param v the value to check against.
79
79
* @param mapping the mapping.
80
80
* @param <R> the type of the produced value.
81
81
* @return the appended sequence of checks.
82
82
*/
83
- public <R extends Expression > BranchesIntermediary <T , R > eq (final T v , final Function <? super T , ? extends R > mapping ) {
83
+ public <R extends MqlValue > BranchesIntermediary <T , R > eq (final T v , final Function <? super T , ? extends R > mapping ) {
84
84
Assertions .notNull ("v" , v );
85
85
Assertions .notNull ("mapping" , mapping );
86
86
return is (value -> value .eq (v ), mapping );
87
87
}
88
88
89
89
/**
90
90
* A successful check for being
91
- * {@linkplain Expression #lt less than}
91
+ * {@linkplain MqlValue #lt less than}
92
92
* the provided value {@code v}
93
93
* produces a value specified by the {@code mapping}.
94
94
*
@@ -97,15 +97,15 @@ public <R extends Expression> BranchesIntermediary<T, R> eq(final T v, final Fun
97
97
* @param <R> the type of the produced value.
98
98
* @return the appended sequence of checks.
99
99
*/
100
- public <R extends Expression > BranchesIntermediary <T , R > lt (final T v , final Function <? super T , ? extends R > mapping ) {
100
+ public <R extends MqlValue > BranchesIntermediary <T , R > lt (final T v , final Function <? super T , ? extends R > mapping ) {
101
101
Assertions .notNull ("v" , v );
102
102
Assertions .notNull ("mapping" , mapping );
103
103
return is (value -> value .lt (v ), mapping );
104
104
}
105
105
106
106
/**
107
107
* A successful check for being
108
- * {@linkplain Expression #lte less than or equal to}
108
+ * {@linkplain MqlValue #lte less than or equal to}
109
109
* the provided value {@code v}
110
110
* produces a value specified by the {@code mapping}.
111
111
*
@@ -114,7 +114,7 @@ public <R extends Expression> BranchesIntermediary<T, R> lt(final T v, final Fun
114
114
* @param <R> the type of the produced value.
115
115
* @return the appended sequence of checks.
116
116
*/
117
- public <R extends Expression > BranchesIntermediary <T , R > lte (final T v , final Function <? super T , ? extends R > mapping ) {
117
+ public <R extends MqlValue > BranchesIntermediary <T , R > lte (final T v , final Function <? super T , ? extends R > mapping ) {
118
118
Assertions .notNull ("v" , v );
119
119
Assertions .notNull ("mapping" , mapping );
120
120
return is (value -> value .lte (v ), mapping );
@@ -124,79 +124,79 @@ public <R extends Expression> BranchesIntermediary<T, R> lte(final T v, final Fu
124
124
125
125
/**
126
126
* A successful check for
127
- * {@linkplain Expression #isBooleanOr(BooleanExpression ) being a boolean}
127
+ * {@linkplain MqlValue #isBooleanOr(MqlBoolean ) being a boolean}
128
128
* produces a value specified by the {@code mapping}.
129
129
*
130
130
* @param mapping the mapping.
131
131
* @return the appended sequence of checks.
132
132
* @param <R> the type of the produced value.
133
133
*/
134
- public <R extends Expression > BranchesIntermediary <T , R > isBoolean (final Function <? super BooleanExpression , ? extends R > mapping ) {
134
+ public <R extends MqlValue > BranchesIntermediary <T , R > isBoolean (final Function <? super MqlBoolean , ? extends R > mapping ) {
135
135
Assertions .notNull ("mapping" , mapping );
136
- return is (v -> mqlEx (v ).isBoolean (), v -> mapping .apply ((BooleanExpression ) v ));
136
+ return is (v -> mqlEx (v ).isBoolean (), v -> mapping .apply ((MqlBoolean ) v ));
137
137
}
138
138
139
139
/**
140
140
* A successful check for
141
- * {@linkplain Expression #isNumberOr(NumberExpression ) being a number}
141
+ * {@linkplain MqlValue #isNumberOr(MqlNumber ) being a number}
142
142
* produces a value specified by the {@code mapping}.
143
143
*
144
144
* @mongodb.server.release 4.4
145
145
* @param mapping the mapping.
146
146
* @return the appended sequence of checks.
147
147
* @param <R> the type of the produced value.
148
148
*/
149
- public <R extends Expression > BranchesIntermediary <T , R > isNumber (final Function <? super NumberExpression , ? extends R > mapping ) {
149
+ public <R extends MqlValue > BranchesIntermediary <T , R > isNumber (final Function <? super MqlNumber , ? extends R > mapping ) {
150
150
Assertions .notNull ("mapping" , mapping );
151
- return is (v -> mqlEx (v ).isNumber (), v -> mapping .apply ((NumberExpression ) v ));
151
+ return is (v -> mqlEx (v ).isNumber (), v -> mapping .apply ((MqlNumber ) v ));
152
152
}
153
153
154
154
/**
155
155
* A successful check for
156
- * {@linkplain Expression #isIntegerOr(IntegerExpression ) being an integer}
156
+ * {@linkplain MqlValue #isIntegerOr(MqlInteger ) being an integer}
157
157
* produces a value specified by the {@code mapping}.
158
158
*
159
159
* @mongodb.server.release 4.4
160
160
* @param mapping the mapping.
161
161
* @return the appended sequence of checks.
162
162
* @param <R> the type of the produced value.
163
163
*/
164
- public <R extends Expression > BranchesIntermediary <T , R > isInteger (final Function <? super IntegerExpression , ? extends R > mapping ) {
164
+ public <R extends MqlValue > BranchesIntermediary <T , R > isInteger (final Function <? super MqlInteger , ? extends R > mapping ) {
165
165
Assertions .notNull ("mapping" , mapping );
166
- return is (v -> mqlEx (v ).isInteger (), v -> mapping .apply ((IntegerExpression ) v ));
166
+ return is (v -> mqlEx (v ).isInteger (), v -> mapping .apply ((MqlInteger ) v ));
167
167
}
168
168
169
169
/**
170
170
* A successful check for
171
- * {@linkplain Expression #isStringOr(StringExpression ) being a string}
171
+ * {@linkplain MqlValue #isStringOr(MqlString ) being a string}
172
172
* produces a value specified by the {@code mapping}.
173
173
*
174
174
* @param mapping the mapping.
175
175
* @return the appended sequence of checks.
176
176
* @param <R> the type of the produced value.
177
177
*/
178
- public <R extends Expression > BranchesIntermediary <T , R > isString (final Function <? super StringExpression , ? extends R > mapping ) {
178
+ public <R extends MqlValue > BranchesIntermediary <T , R > isString (final Function <? super MqlString , ? extends R > mapping ) {
179
179
Assertions .notNull ("mapping" , mapping );
180
- return is (v -> mqlEx (v ).isString (), v -> mapping .apply ((StringExpression ) v ));
180
+ return is (v -> mqlEx (v ).isString (), v -> mapping .apply ((MqlString ) v ));
181
181
}
182
182
183
183
/**
184
184
* A successful check for
185
- * {@linkplain Expression #isDateOr(DateExpression ) being a date}
185
+ * {@linkplain MqlValue #isDateOr(MqlDate ) being a date}
186
186
* produces a value specified by the {@code mapping}.
187
187
*
188
188
* @param mapping the mapping.
189
189
* @return the appended sequence of checks.
190
190
* @param <R> the type of the produced value.
191
191
*/
192
- public <R extends Expression > BranchesIntermediary <T , R > isDate (final Function <? super DateExpression , ? extends R > mapping ) {
192
+ public <R extends MqlValue > BranchesIntermediary <T , R > isDate (final Function <? super MqlDate , ? extends R > mapping ) {
193
193
Assertions .notNull ("mapping" , mapping );
194
- return is (v -> mqlEx (v ).isDate (), v -> mapping .apply ((DateExpression ) v ));
194
+ return is (v -> mqlEx (v ).isDate (), v -> mapping .apply ((MqlDate ) v ));
195
195
}
196
196
197
197
/**
198
198
* A successful check for
199
- * {@linkplain Expression #isArrayOr(ArrayExpression ) being an array}
199
+ * {@linkplain MqlValue #isArrayOr(MqlArray ) being an array}
200
200
* produces a value specified by the {@code mapping}.
201
201
*
202
202
* <p>Warning: The type argument of the array is not
@@ -209,32 +209,32 @@ public <R extends Expression> BranchesIntermediary<T, R> isDate(final Function<?
209
209
* @param <Q> the type of the array.
210
210
*/
211
211
@ SuppressWarnings ("unchecked" )
212
- public <R extends Expression , Q extends Expression > BranchesIntermediary <T , R > isArray (final Function <? super ArrayExpression <@ MqlUnchecked (TYPE_ARGUMENT ) Q >, ? extends R > mapping ) {
212
+ public <R extends MqlValue , Q extends MqlValue > BranchesIntermediary <T , R > isArray (final Function <? super MqlArray <@ MqlUnchecked (TYPE_ARGUMENT ) Q >, ? extends R > mapping ) {
213
213
Assertions .notNull ("mapping" , mapping );
214
- return is (v -> mqlEx (v ).isArray (), v -> mapping .apply ((ArrayExpression <Q >) v ));
214
+ return is (v -> mqlEx (v ).isArray (), v -> mapping .apply ((MqlArray <Q >) v ));
215
215
}
216
216
217
217
/**
218
218
* A successful check for
219
- * {@linkplain Expression #isDocumentOr(DocumentExpression ) being a document}
219
+ * {@linkplain MqlValue #isDocumentOr(MqlDocument ) being a document}
220
220
* (or document-like value, see
221
- * {@link MapExpression } and {@link EntryExpression })
221
+ * {@link MqlMap } and {@link MqlEntry })
222
222
* produces a value specified by the {@code mapping}.
223
223
*
224
224
* @param mapping the mapping.
225
225
* @return the appended sequence of checks.
226
226
* @param <R> the type of the produced value.
227
227
*/
228
- public <R extends Expression > BranchesIntermediary <T , R > isDocument (final Function <? super DocumentExpression , ? extends R > mapping ) {
228
+ public <R extends MqlValue > BranchesIntermediary <T , R > isDocument (final Function <? super MqlDocument , ? extends R > mapping ) {
229
229
Assertions .notNull ("mapping" , mapping );
230
- return is (v -> mqlEx (v ).isDocumentOrMap (), v -> mapping .apply ((DocumentExpression ) v ));
230
+ return is (v -> mqlEx (v ).isDocumentOrMap (), v -> mapping .apply ((MqlDocument ) v ));
231
231
}
232
232
233
233
/**
234
234
* A successful check for
235
- * {@linkplain Expression #isMapOr(MapExpression ) being a map}
235
+ * {@linkplain MqlValue #isMapOr(MqlMap ) being a map}
236
236
* (or map-like value, see
237
- * {@link DocumentExpression } and {@link EntryExpression })
237
+ * {@link MqlDocument } and {@link MqlEntry })
238
238
* produces a value specified by the {@code mapping}.
239
239
*
240
240
* <p>Warning: The type argument of the map is not
@@ -247,21 +247,21 @@ public <R extends Expression> BranchesIntermediary<T, R> isDocument(final Functi
247
247
* @param <Q> the type of the array.
248
248
*/
249
249
@ SuppressWarnings ("unchecked" )
250
- public <R extends Expression , Q extends Expression > BranchesIntermediary <T , R > isMap (final Function <? super MapExpression <@ MqlUnchecked (TYPE_ARGUMENT ) Q >, ? extends R > mapping ) {
250
+ public <R extends MqlValue , Q extends MqlValue > BranchesIntermediary <T , R > isMap (final Function <? super MqlMap <@ MqlUnchecked (TYPE_ARGUMENT ) Q >, ? extends R > mapping ) {
251
251
Assertions .notNull ("mapping" , mapping );
252
- return is (v -> mqlEx (v ).isDocumentOrMap (), v -> mapping .apply ((MapExpression <Q >) v ));
252
+ return is (v -> mqlEx (v ).isDocumentOrMap (), v -> mapping .apply ((MqlMap <Q >) v ));
253
253
}
254
254
255
255
/**
256
256
* A successful check for
257
- * {@linkplain Expressions #ofNull()} being the null value}
257
+ * {@linkplain MqlValues #ofNull()} being the null value}
258
258
* produces a value specified by the {@code mapping}.
259
259
*
260
260
* @param mapping the mapping.
261
261
* @return the appended sequence of checks.
262
262
* @param <R> the type of the produced value.
263
263
*/
264
- public <R extends Expression > BranchesIntermediary <T , R > isNull (final Function <? super Expression , ? extends R > mapping ) {
264
+ public <R extends MqlValue > BranchesIntermediary <T , R > isNull (final Function <? super MqlValue , ? extends R > mapping ) {
265
265
Assertions .notNull ("mapping" , mapping );
266
266
return is (v -> mqlEx (v ).isNull (), v -> mapping .apply (v ));
267
267
}
0 commit comments