11package com .redis .om .spring .metamodel .indexed ;
22
3+ import java .util .ArrayList ;
34import java .util .Arrays ;
5+ import java .util .Collection ;
46import java .util .List ;
57import java .util .function .Consumer ;
68
@@ -137,7 +139,7 @@ public BetweenPredicate<E, T> between(T min, T max) {
137139
138140 /**
139141 * Creates an in predicate for this numeric field to match any of the specified values.
140- *
142+ *
141143 * @param values the values to match against
142144 * @return an InPredicate that matches entities where this field equals any of the specified values
143145 */
@@ -148,6 +150,22 @@ public BetweenPredicate<E, T> between(T min, T max) {
148150 return new InPredicate <>(searchFieldAccessor , Arrays .asList (values ));
149151 }
150152
153+ /**
154+ * Creates an in predicate for this numeric field to match any of the specified values from a collection.
155+ * <p>
156+ * This is useful when you already have your values in a Collection (List, Set, etc.) and want to
157+ * avoid converting to an array.
158+ *
159+ * @param values the collection of values to match against
160+ * @return an InPredicate that matches entities where this field equals any of the specified values
161+ */
162+ @ SuppressWarnings (
163+ "unchecked"
164+ )
165+ public InPredicate <E , ?> in (Collection <T > values ) {
166+ return new InPredicate <>(searchFieldAccessor , new ArrayList <>(values ));
167+ }
168+
151169 /**
152170 * Creates an increment action for this numeric field.
153171 *
@@ -172,7 +190,7 @@ public Consumer<E> decrBy(Long value) {
172190 * Creates an array membership predicate for this numeric field to check if the array contains any of the specified
173191 * Double values.
174192 * This method is similar to TagField.in() but for numeric arrays.
175- *
193+ *
176194 * @param values the Double values to check for membership in the array
177195 * @return an InPredicate that matches entities where this numeric array field contains any of the specified values
178196 */
@@ -183,11 +201,28 @@ public Consumer<E> decrBy(Long value) {
183201 return new InPredicate <>(searchFieldAccessor , Arrays .asList (values ));
184202 }
185203
204+ /**
205+ * Creates an array membership predicate for this numeric field to check if the array contains any of the specified
206+ * Double values from a collection.
207+ * <p>
208+ * This is useful when you already have your Double values in a Collection (List, Set, etc.) and want to
209+ * avoid converting to an array.
210+ *
211+ * @param values the collection of Double values to check for membership in the array
212+ * @return an InPredicate that matches entities where this numeric array field contains any of the specified values
213+ */
214+ @ SuppressWarnings (
215+ "unchecked"
216+ )
217+ public InPredicate <E , ?> containsDouble (Collection <Double > values ) {
218+ return new InPredicate <>(searchFieldAccessor , new ArrayList <>(values ));
219+ }
220+
186221 /**
187222 * Creates an array membership predicate for this numeric field to check if the array contains any of the specified
188223 * Long values.
189224 * This method is similar to TagField.in() but for numeric arrays.
190- *
225+ *
191226 * @param values the Long values to check for membership in the array
192227 * @return an InPredicate that matches entities where this numeric array field contains any of the specified values
193228 */
@@ -198,11 +233,28 @@ public Consumer<E> decrBy(Long value) {
198233 return new InPredicate <>(searchFieldAccessor , Arrays .asList (values ));
199234 }
200235
236+ /**
237+ * Creates an array membership predicate for this numeric field to check if the array contains any of the specified
238+ * Long values from a collection.
239+ * <p>
240+ * This is useful when you already have your Long values in a Collection (List, Set, etc.) and want to
241+ * avoid converting to an array.
242+ *
243+ * @param values the collection of Long values to check for membership in the array
244+ * @return an InPredicate that matches entities where this numeric array field contains any of the specified values
245+ */
246+ @ SuppressWarnings (
247+ "unchecked"
248+ )
249+ public InPredicate <E , ?> containsLong (Collection <Long > values ) {
250+ return new InPredicate <>(searchFieldAccessor , new ArrayList <>(values ));
251+ }
252+
201253 /**
202254 * Creates an array membership predicate for this numeric field to check if the array contains any of the specified
203255 * Integer values.
204256 * This method is similar to TagField.in() but for numeric arrays.
205- *
257+ *
206258 * @param values the Integer values to check for membership in the array
207259 * @return an InPredicate that matches entities where this numeric array field contains any of the specified values
208260 */
@@ -213,4 +265,21 @@ public Consumer<E> decrBy(Long value) {
213265 return new InPredicate <>(searchFieldAccessor , Arrays .asList (values ));
214266 }
215267
268+ /**
269+ * Creates an array membership predicate for this numeric field to check if the array contains any of the specified
270+ * Integer values from a collection.
271+ * <p>
272+ * This is useful when you already have your Integer values in a Collection (List, Set, etc.) and want to
273+ * avoid converting to an array.
274+ *
275+ * @param values the collection of Integer values to check for membership in the array
276+ * @return an InPredicate that matches entities where this numeric array field contains any of the specified values
277+ */
278+ @ SuppressWarnings (
279+ "unchecked"
280+ )
281+ public InPredicate <E , ?> containsInt (Collection <Integer > values ) {
282+ return new InPredicate <>(searchFieldAccessor , new ArrayList <>(values ));
283+ }
284+
216285}
0 commit comments