@@ -66,11 +66,12 @@ public static BooleanExpression of(final boolean of) {
66
66
* @return the boolean array expression
67
67
*/
68
68
public static ArrayExpression <BooleanExpression > ofBooleanArray (final boolean ... array ) {
69
- List <BsonValue > result = new ArrayList <>();
69
+ Assertions .notNull ("array" , array );
70
+ List <BsonValue > list = new ArrayList <>();
70
71
for (boolean b : array ) {
71
- result .add (new BsonBoolean (b ));
72
+ list .add (new BsonBoolean (b ));
72
73
}
73
- return new MqlExpression <>((cr ) -> new AstPlaceholder (new BsonArray (result )));
74
+ return new MqlExpression <>((cr ) -> new AstPlaceholder (new BsonArray (list )));
74
75
}
75
76
76
77
/**
@@ -85,9 +86,11 @@ public static IntegerExpression of(final int of) {
85
86
}
86
87
87
88
public static ArrayExpression <IntegerExpression > ofIntegerArray (final int ... array ) {
88
- List <BsonValue > list = Arrays .stream (array )
89
- .mapToObj (BsonInt32 ::new )
90
- .collect (Collectors .toList ());
89
+ Assertions .notNull ("array" , array );
90
+ List <BsonValue > list = new ArrayList <>();
91
+ for (int i : array ) {
92
+ list .add (new BsonInt32 (i ));
93
+ }
91
94
return new MqlExpression <>((cr ) -> new AstPlaceholder (new BsonArray (list )));
92
95
}
93
96
@@ -96,9 +99,11 @@ public static IntegerExpression of(final long of) {
96
99
}
97
100
98
101
public static ArrayExpression <IntegerExpression > ofIntegerArray (final long ... array ) {
99
- List <BsonValue > list = Arrays .stream (array )
100
- .mapToObj (BsonInt64 ::new )
101
- .collect (Collectors .toList ());
102
+ Assertions .notNull ("array" , array );
103
+ List <BsonValue > list = new ArrayList <>();
104
+ for (long i : array ) {
105
+ list .add (new BsonInt64 (i ));
106
+ }
102
107
return new MqlExpression <>((cr ) -> new AstPlaceholder (new BsonArray (list )));
103
108
}
104
109
@@ -107,9 +112,11 @@ public static NumberExpression of(final double of) {
107
112
}
108
113
109
114
public static ArrayExpression <NumberExpression > ofNumberArray (final double ... array ) {
110
- List <BsonValue > list = Arrays .stream (array )
111
- .mapToObj (BsonDouble ::new )
112
- .collect (Collectors .toList ());
115
+ Assertions .notNull ("array" , array );
116
+ List <BsonValue > list = new ArrayList <>();
117
+ for (double n : array ) {
118
+ list .add (new BsonDouble (n ));
119
+ }
113
120
return new MqlExpression <>((cr ) -> new AstPlaceholder (new BsonArray (list )));
114
121
}
115
122
@@ -119,6 +126,7 @@ public static NumberExpression of(final Decimal128 of) {
119
126
}
120
127
121
128
public static ArrayExpression <NumberExpression > ofNumberArray (final Decimal128 ... array ) {
129
+ Assertions .notNull ("array" , array );
122
130
List <BsonValue > result = new ArrayList <>();
123
131
for (Decimal128 e : array ) {
124
132
Assertions .notNull ("elements of array" , e );
@@ -133,6 +141,7 @@ public static DateExpression of(final Instant of) {
133
141
}
134
142
135
143
public static ArrayExpression <DateExpression > ofDateArray (final Instant ... array ) {
144
+ Assertions .notNull ("array" , array );
136
145
List <BsonValue > result = new ArrayList <>();
137
146
for (Instant e : array ) {
138
147
Assertions .notNull ("elements of array" , e );
@@ -155,6 +164,7 @@ public static StringExpression of(final String of) {
155
164
156
165
157
166
public static ArrayExpression <StringExpression > ofStringArray (final String ... array ) {
167
+ Assertions .notNull ("array" , array );
158
168
List <BsonValue > result = new ArrayList <>();
159
169
for (String e : array ) {
160
170
Assertions .notNull ("elements of array" , e );
@@ -167,10 +177,12 @@ public static ArrayExpression<StringExpression> ofStringArray(final String... ar
167
177
public static <T extends Expression > ArrayExpression <T > ofArray (final T ... array ) {
168
178
Assertions .notNull ("array" , array );
169
179
return new MqlExpression <>((cr ) -> {
170
- List <BsonValue > array2 = Arrays .stream (array )
171
- .map (v -> ((MqlExpression <?>) v ).toBsonValue (cr ))
172
- .collect (Collectors .toList ());
173
- return new AstPlaceholder (new BsonArray (array2 ));
180
+ List <BsonValue > list = new ArrayList <>();
181
+ for (T v : array ) {
182
+ Assertions .notNull ("elements of array" , v );
183
+ list .add (((MqlExpression <?>) v ).toBsonValue (cr ));
184
+ }
185
+ return new AstPlaceholder (new BsonArray (list ));
174
186
});
175
187
}
176
188
@@ -189,6 +201,7 @@ public static <R extends Expression> R ofNull() {
189
201
}
190
202
191
203
static NumberExpression numberToExpression (final Number number ) {
204
+ Assertions .notNull ("number" , number );
192
205
if (number instanceof Integer ) {
193
206
return of ((int ) number );
194
207
} else if (number instanceof Long ) {
0 commit comments