1515 */
1616package io.getstream.android.core.api.filter
1717
18- import io.getstream.android.core.internal.filter.FilterOperator
18+ import io.getstream.android.core.internal.filter.BinaryOperator
19+ import io.getstream.android.core.internal.filter.CollectionOperator
1920
2021/* * Utility class for building filters. */
2122public object Filters {
@@ -25,17 +26,17 @@ public object Filters {
2526 * @param filters The filters to combine.
2627 * @return A filter that matches when all provided filters match.
2728 */
28- public fun <F : FilterField > and (vararg filters : Filter <F >): Filter <F > =
29- CollectionOperationFilter (FilterOperator .AND , filters.toSet())
29+ public fun <M , F : FilterField < M >> and (vararg filters : Filter <M , F >): Filter <M , F > =
30+ CollectionOperationFilter (CollectionOperator .AND , filters.toSet())
3031
3132 /* *
3233 * Creates a filter that combines multiple filters with a logical OR operation.
3334 *
3435 * @param filters The filters to combine.
3536 * @return A filter that matches when any of the specified filters match.
3637 */
37- public fun <F : FilterField > or (vararg filters : Filter <F >): Filter <F > =
38- CollectionOperationFilter (FilterOperator .OR , filters.toSet())
38+ public fun <M , F : FilterField < M >> or (vararg filters : Filter <M , F >): Filter <M , F > =
39+ CollectionOperationFilter (CollectionOperator .OR , filters.toSet())
3940}
4041
4142/* *
@@ -44,111 +45,111 @@ public object Filters {
4445 * @param value The value to check equality against.
4546 * @return A filter that matches when this field equals the specified value.
4647 */
47- public fun <F : FilterField > F.equal (value : Any ): Filter <F > =
48- BinaryOperationFilter (FilterOperator .EQUAL , this , value)
48+ public fun <M , F : FilterField < M >> F.equal (value : Any ): Filter <M , F > =
49+ BinaryOperationFilter (BinaryOperator .EQUAL , this , value)
4950
5051/* *
5152 * Creates a filter that checks if this field is greater than a specific value.
5253 *
5354 * @param value The value to check against.
5455 * @return A filter that matches when this field is greater than the specified value.
5556 */
56- public fun <F : FilterField > F.greater (value : Any ): Filter <F > =
57- BinaryOperationFilter (FilterOperator .GREATER , this , value)
57+ public fun <M , F : FilterField < M >> F.greater (value : Any ): Filter <M , F > =
58+ BinaryOperationFilter (BinaryOperator .GREATER , this , value)
5859
5960/* *
6061 * Creates a filter that checks if this field is greater than or equal to a specific value.
6162 *
6263 * @param value The value to check against.
6364 * @return A filter that matches when this field is greater than or equal to the specified value.
6465 */
65- public fun <F : FilterField > F.greaterOrEqual (value : Any ): Filter <F > =
66- BinaryOperationFilter (FilterOperator .GREATER_OR_EQUAL , this , value)
66+ public fun <M , F : FilterField < M >> F.greaterOrEqual (value : Any ): Filter <M , F > =
67+ BinaryOperationFilter (BinaryOperator .GREATER_OR_EQUAL , this , value)
6768
6869/* *
6970 * Creates a filter that checks if this field is less than a specific value.
7071 *
7172 * @param value The value to check against.
7273 * @return A filter that matches when this field is less than the specified value.
7374 */
74- public fun <F : FilterField > F.less (value : Any ): Filter <F > =
75- BinaryOperationFilter (FilterOperator .LESS , this , value)
75+ public fun <M , F : FilterField < M >> F.less (value : Any ): Filter <M , F > =
76+ BinaryOperationFilter (BinaryOperator .LESS , this , value)
7677
7778/* *
7879 * Creates a filter that checks if this field is less than or equal to a specific value.
7980 *
8081 * @param value The value to check against.
8182 * @return A filter that matches when this field is less than or equal to the specified value.
8283 */
83- public fun <F : FilterField > F.lessOrEqual (value : Any ): Filter <F > =
84- BinaryOperationFilter (FilterOperator .LESS_OR_EQUAL , this , value)
84+ public fun <M , F : FilterField < M >> F.lessOrEqual (value : Any ): Filter <M , F > =
85+ BinaryOperationFilter (BinaryOperator .LESS_OR_EQUAL , this , value)
8586
8687/* *
8788 * Creates a filter that checks if this field's value is in a specific list of values.
8889 *
8990 * @param values The list of values to check against.
9091 * @return A filter that matches when this field's value is in the specified list.
9192 */
92- public fun <F : FilterField > F .`in` (values : List <Any >): Filter <F > =
93- BinaryOperationFilter (FilterOperator .IN , this , values.toSet())
93+ public fun <M , F : FilterField < M >> F .`in` (values : List <Any >): Filter <M , F > =
94+ BinaryOperationFilter (BinaryOperator .IN , this , values.toSet())
9495
9596/* *
9697 * Creates a filter that checks if this field's value is in a specific set of values.
9798 *
9899 * @param values The values to check against.
99100 * @return A filter that matches when this field's value is in the specified values.
100101 */
101- public fun <F : FilterField > F .`in` (vararg values : Any ): Filter <F > =
102- BinaryOperationFilter (FilterOperator .IN , this , values.toSet())
102+ public fun <M , F : FilterField < M >> F .`in` (vararg values : Any ): Filter <M , F > =
103+ BinaryOperationFilter (BinaryOperator .IN , this , values.toSet())
103104
104105/* *
105106 * Creates a filter that performs a full-text query on this field.
106107 *
107108 * @param value The query string to search for.
108109 * @return A filter that matches based on the full-text query.
109110 */
110- public fun <F : FilterField > F.query (value : String ): Filter <F > =
111- BinaryOperationFilter (FilterOperator .QUERY , this , value)
111+ public fun <M , F : FilterField < M >> F.query (value : String ): Filter <M , F > =
112+ BinaryOperationFilter (BinaryOperator .QUERY , this , value)
112113
113114/* *
114115 * Creates a filter that performs autocomplete matching on this field.
115116 *
116117 * @param value The string to autocomplete against.
117118 * @return A filter that matches based on autocomplete functionality.
118119 */
119- public fun <F : FilterField > F.autocomplete (value : String ): Filter <F > =
120- BinaryOperationFilter (FilterOperator .AUTOCOMPLETE , this , value)
120+ public fun <M , F : FilterField < M >> F.autocomplete (value : String ): Filter <M , F > =
121+ BinaryOperationFilter (BinaryOperator .AUTOCOMPLETE , this , value)
121122
122123/* *
123124 * Creates a filter that checks if this field exists.
124125 *
125126 * @return A filter that matches when this field exists.
126127 */
127- public fun <F : FilterField > F.exists (): Filter <F > =
128- BinaryOperationFilter (FilterOperator .EXISTS , this , true )
128+ public fun <M , F : FilterField < M >> F.exists (): Filter <M , F > =
129+ BinaryOperationFilter (BinaryOperator .EXISTS , this , true )
129130
130131/* *
131132 * Creates a filter that checks if this field does not exist.
132133 *
133134 * @return A filter that matches when this field does not exist.
134135 */
135- public fun <F : FilterField > F.doesNotExist (): Filter <F > =
136- BinaryOperationFilter (FilterOperator .EXISTS , this , false )
136+ public fun <M , F : FilterField < M >> F.doesNotExist (): Filter <M , F > =
137+ BinaryOperationFilter (BinaryOperator .EXISTS , this , false )
137138
138139/* *
139140 * Creates a filter that checks if this field contains a specific value.
140141 *
141142 * @param value The value to check for within this field.
142143 * @return A filter that matches when this field contains the specified value.
143144 */
144- public fun <F : FilterField > F.contains (value : Any ): Filter <F > =
145- BinaryOperationFilter (FilterOperator .CONTAINS , this , value)
145+ public fun <M , F : FilterField < M >> F.contains (value : Any ): Filter <M , F > =
146+ BinaryOperationFilter (BinaryOperator .CONTAINS , this , value)
146147
147148/* *
148149 * Creates a filter that checks if a specific path exists within this field.
149150 *
150151 * @param value The path to check for existence.
151152 * @return A filter that matches when the specified path exists in this field.
152153 */
153- public fun <F : FilterField > F.pathExists (value : String ): Filter <F > =
154- BinaryOperationFilter (FilterOperator .PATH_EXISTS , this , value)
154+ public fun <M , F : FilterField < M >> F.pathExists (value : String ): Filter <M , F > =
155+ BinaryOperationFilter (BinaryOperator .PATH_EXISTS , this , value)
0 commit comments