Skip to content

Commit 14df144

Browse files
committed
Add javadocs for remaining classes (#1070)
JAVA-4799
1 parent c4c7e4b commit 14df144

File tree

12 files changed

+1320
-144
lines changed

12 files changed

+1320
-144
lines changed

driver-core/src/main/com/mongodb/client/model/expressions/ArrayExpression.java

Lines changed: 211 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121
import static com.mongodb.client.model.expressions.Expressions.of;
2222
import static com.mongodb.client.model.expressions.MqlUnchecked.Unchecked.PRESENT;
23-
import static com.mongodb.client.model.expressions.MqlUnchecked.Unchecked.NON_EMPTY;
2423

2524
/**
2625
* An array {@link Expression value} in the context of the MongoDB Query
@@ -58,67 +57,267 @@ public interface ArrayExpression<T extends Expression> extends Expression {
5857
*/
5958
IntegerExpression size();
6059

60+
/**
61+
* True if any value in {@code this} array satisfies the predicate.
62+
*
63+
* @param predicate the predicate.
64+
* @return the resulting value.
65+
*/
6166
BooleanExpression any(Function<? super T, BooleanExpression> predicate);
6267

68+
/**
69+
* True if all values in {@code this} array satisfy the predicate.
70+
*
71+
* @param predicate the predicate.
72+
* @return the resulting value.
73+
*/
6374
BooleanExpression all(Function<? super T, BooleanExpression> predicate);
6475

76+
/**
77+
* The sum of adding together all the values of {@code this} array,
78+
* via the provided {@code mapper}. Returns 0 if the array is empty.
79+
*
80+
* <p>The mapper may be used to transform the values of {@code this} array
81+
* into {@linkplain NumberExpression numbers}. If no transformation is
82+
* necessary, then the identify function {@code array.sum(v -> v)} should
83+
* be used.
84+
*
85+
* @param mapper the mapper function.
86+
* @return the resulting value.
87+
*/
6588
NumberExpression sum(Function<? super T, ? extends NumberExpression> mapper);
6689

90+
/**
91+
* The product of multiplying together all the values of {@code this} array,
92+
* via the provided {@code mapper}. Returns 1 if the array is empty.
93+
*
94+
* <p>The mapper may be used to transform the values of {@code this} array
95+
* into {@linkplain NumberExpression numbers}. If no transformation is
96+
* necessary, then the identify function {@code array.multiply(v -> v)}
97+
* should be used.
98+
*
99+
* @param mapper the mapper function.
100+
* @return the resulting value.
101+
*/
67102
NumberExpression multiply(Function<? super T, ? extends NumberExpression> mapper);
68103

104+
/**
105+
* The {@linkplain #gt(Expression) largest} value all the values of
106+
* {@code this} array, or the {@code other} value if this array is empty.
107+
*
108+
* @param other the other value.
109+
* @return the resulting value.
110+
*/
69111
T max(T other);
70112

113+
/**
114+
* The {@linkplain #lt(Expression) smallest} value all the values of
115+
* {@code this} array, or the {@code other} value if this array is empty.
116+
*
117+
* @param other the other value.
118+
* @return the resulting value.
119+
*/
71120
T min(T other);
72121

122+
/**
123+
* The {@linkplain #gt(Expression) largest} {@code n} elements of
124+
* {@code this} array, or all elements if the array contains fewer than
125+
* {@code n} elements.
126+
*
127+
* @param n the number of elements.
128+
* @return the resulting value.
129+
*/
73130
ArrayExpression<T> maxN(IntegerExpression n);
131+
132+
/**
133+
* The {@linkplain #lt(Expression) smallest} {@code n} elements of
134+
* {@code this} array, or all elements if the array contains fewer than
135+
* {@code n} elements.
136+
*
137+
* @param n the number of elements.
138+
* @return the resulting value.
139+
*/
74140
ArrayExpression<T> minN(IntegerExpression n);
75141

142+
/**
143+
* The string-concatenation of all the values of {@code this} array,
144+
* via the provided {@code mapper}. Returns the empty string if the array
145+
* is empty.
146+
*
147+
* <p>The mapper may be used to transform the values of {@code this} array
148+
* into {@linkplain StringExpression strings}. If no transformation is
149+
* necessary, then the identify function {@code array.join(v -> v)} should
150+
* be used.
151+
*
152+
* @param mapper the mapper function.
153+
* @return the resulting value.
154+
*/
76155
StringExpression join(Function<? super T, StringExpression> mapper);
77156

157+
/**
158+
* The array-concatenation of all the array values of {@code this} array,
159+
* via the provided {@code mapper}. Returns the empty array if the array
160+
* is empty.
161+
*
162+
* <p>The mapper may be used to transform the values of {@code this} array
163+
* into {@linkplain ArrayExpression arrays}. If no transformation is
164+
* necessary, then the identify function {@code array.concat(v -> v)} should
165+
* be used.
166+
*
167+
* @param mapper the mapper function.
168+
* @return the resulting value.
169+
* @param <R> the type of the elements of the array.
170+
*/
78171
<R extends Expression> ArrayExpression<R> concat(Function<? super T, ? extends ArrayExpression<? extends R>> mapper);
79172

173+
/**
174+
* The set union of all the array values of {@code this} array,
175+
* via the provided {@code mapper}. Returns the empty array if the array
176+
* is empty.
177+
*
178+
* <p>The mapper may be used to transform the values of {@code this} array
179+
* into {@linkplain ArrayExpression arrays}. If no transformation is
180+
* necessary, then the identify function {@code array.union(v -> v)} should
181+
* be used.
182+
*
183+
* @param mapper the mapper function.
184+
* @return the resulting value.
185+
* @param <R> the type of the elements of the array.
186+
*/
80187
<R extends Expression> ArrayExpression<R> union(Function<? super T, ? extends ArrayExpression<? extends R>> mapper);
81188

189+
/**
190+
* The {@linkplain MapExpression map} value corresponding to the
191+
* {@linkplain EntryExpression entry} values of {@code this} array,
192+
* via the provided {@code mapper}. Returns the empty array if the array
193+
* is empty.
194+
*
195+
* <p>The mapper may be used to transform the values of {@code this} array
196+
* into {@linkplain EntryExpression entries}. If no transformation is
197+
* necessary, then the identify function {@code array.union(v -> v)} should
198+
* be used.
199+
*
200+
* @see MapExpression#entrySet()
201+
* @param mapper the mapper function.
202+
* @return the resulting value.
203+
* @param <R> the type of the resulting map's values.
204+
*/
82205
<R extends Expression> MapExpression<R> asMap(Function<? super T, ? extends EntryExpression<? extends R>> mapper);
83206

84207
/**
85-
* user asserts that i is in bounds for the array
208+
* Returns the element at the provided index {@code i} for
209+
* {@code this} array.
86210
*
87-
* @param i
88-
* @return
211+
* <p>Warning: The use of this method is an assertion that
212+
* the index {@code i} is in bounds for the array.
213+
* If the index is out of bounds for this array, then
214+
* the behaviour of the API is not defined.
215+
*
216+
* @param i the index.
217+
* @return the resulting value.
89218
*/
90219
@MqlUnchecked(PRESENT)
91220
T elementAt(IntegerExpression i);
92221

222+
/**
223+
* Returns the element at the provided index {@code i} for
224+
* {@code this} array.
225+
*
226+
* <p>Warning: The use of this method is an assertion that
227+
* the index {@code i} is in bounds for the array.
228+
* If the index is out of bounds for this array, then
229+
* the behaviour of the API is not defined.
230+
*
231+
* @param i the index.
232+
* @return the resulting value.
233+
*/
234+
@MqlUnchecked(PRESENT)
93235
default T elementAt(final int i) {
94236
return this.elementAt(of(i));
95237
}
96238

97239
/**
98-
* user asserts that array is not empty
99-
* @return
240+
* Returns the first element of {@code this} array.
241+
*
242+
* <p>Warning: The use of this method is an assertion that
243+
* the array is not empty.
244+
* If the array is empty then the behaviour of the API is not defined.
245+
*
246+
* @return the resulting value.
100247
*/
101-
@MqlUnchecked(NON_EMPTY)
248+
@MqlUnchecked(PRESENT)
102249
T first();
103250

104251
/**
105-
* user asserts that array is not empty
106-
* @return
252+
* Returns the last element of {@code this} array.
253+
*
254+
* <p>Warning: The use of this method is an assertion that
255+
* the array is not empty.
256+
* If the array is empty then the behaviour of the API is not defined.
257+
*
258+
* @return the resulting value.
107259
*/
108260
T last();
109261

110-
BooleanExpression contains(T contains);
262+
/**
263+
* True if {@code this} array contains a value that is
264+
* {@linkplain #eq equal} to the provided {@code value}.
265+
*
266+
* @param value the value.
267+
* @return the resulting value.
268+
*/
269+
BooleanExpression contains(T value);
111270

112-
ArrayExpression<T> concat(ArrayExpression<? extends T> array);
271+
/**
272+
* The result of concatenating {@code this} array first with
273+
* the {@code other} array ensuing.
274+
*
275+
* @param other the other array.
276+
* @return the resulting array.
277+
*/
278+
ArrayExpression<T> concat(ArrayExpression<? extends T> other);
113279

280+
/**
281+
* The subarray of {@code this} array, from the {@code start} index
282+
* inclusive, and continuing for the specified {@code length}, up to
283+
* the end of the array.
284+
*
285+
* @param start start index
286+
* @param length length
287+
* @return the resulting value
288+
*/
114289
ArrayExpression<T> slice(IntegerExpression start, IntegerExpression length);
115290

291+
/**
292+
* The subarray of {@code this} array, from the {@code start} index
293+
* inclusive, and continuing for the specified {@code length}, or
294+
* to the end of the array.
295+
*
296+
* @param start start index
297+
* @param length length
298+
* @return the resulting value
299+
*/
116300
default ArrayExpression<T> slice(final int start, final int length) {
117301
return this.slice(of(start), of(length));
118302
}
119303

120-
ArrayExpression<T> union(ArrayExpression<? extends T> set);
304+
/**
305+
* The set-union of {@code this} array and the {@code other} array ensuing,
306+
* containing only the distinct values of both.
307+
* No guarantee is made regarding order.
308+
*
309+
* @param other the other array.
310+
* @return the resulting array.
311+
*/
312+
ArrayExpression<T> union(ArrayExpression<? extends T> other);
313+
121314

315+
/**
316+
* An array containing only the distinct values of {@code this} array.
317+
* No guarantee is made regarding order.
318+
*
319+
* @return the resulting value
320+
*/
122321
ArrayExpression<T> distinct();
123322

124323
/**

0 commit comments

Comments
 (0)