1515 */
1616package io.getstream.android.core.api.filter
1717
18- import io.getstream.android.core.internal.filter.FilterOperator
18+ import io.getstream.android.core.annotations.StreamPublishedApi
19+ import io.getstream.android.core.internal.filter.BinaryOperator
20+ import io.getstream.android.core.internal.filter.CollectionOperator
1921
2022/* * Utility class for building filters. */
2123public object Filters {
@@ -25,17 +27,19 @@ public object Filters {
2527 * @param filters The filters to combine.
2628 * @return A filter that matches when all provided filters match.
2729 */
28- public fun <F : FilterField > and (vararg filters : Filter <F >): Filter <F > =
29- CollectionOperationFilter (FilterOperator .AND , filters.toSet())
30+ @StreamPublishedApi
31+ public fun <M , F : FilterField <M >> and (vararg filters : Filter <M , F >): Filter <M , F > =
32+ CollectionOperationFilter (CollectionOperator .AND , filters.toSet())
3033
3134 /* *
3235 * Creates a filter that combines multiple filters with a logical OR operation.
3336 *
3437 * @param filters The filters to combine.
3538 * @return A filter that matches when any of the specified filters match.
3639 */
37- public fun <F : FilterField > or (vararg filters : Filter <F >): Filter <F > =
38- CollectionOperationFilter (FilterOperator .OR , filters.toSet())
40+ @StreamPublishedApi
41+ public fun <M , F : FilterField <M >> or (vararg filters : Filter <M , F >): Filter <M , F > =
42+ CollectionOperationFilter (CollectionOperator .OR , filters.toSet())
3943}
4044
4145/* *
@@ -44,111 +48,124 @@ public object Filters {
4448 * @param value The value to check equality against.
4549 * @return A filter that matches when this field equals the specified value.
4650 */
47- public fun <F : FilterField > F.equal (value : Any ): Filter <F > =
48- BinaryOperationFilter (FilterOperator .EQUAL , this , value)
51+ @StreamPublishedApi
52+ public fun <M , F : FilterField <M >> F.equal (value : Any ): Filter <M , F > =
53+ BinaryOperationFilter (BinaryOperator .EQUAL , this , value)
4954
5055/* *
5156 * Creates a filter that checks if this field is greater than a specific value.
5257 *
5358 * @param value The value to check against.
5459 * @return A filter that matches when this field is greater than the specified value.
5560 */
56- public fun <F : FilterField > F.greater (value : Any ): Filter <F > =
57- BinaryOperationFilter (FilterOperator .GREATER , this , value)
61+ @StreamPublishedApi
62+ public fun <M , F : FilterField <M >> F.greater (value : Any ): Filter <M , F > =
63+ BinaryOperationFilter (BinaryOperator .GREATER , this , value)
5864
5965/* *
6066 * Creates a filter that checks if this field is greater than or equal to a specific value.
6167 *
6268 * @param value The value to check against.
6369 * @return A filter that matches when this field is greater than or equal to the specified value.
6470 */
65- public fun <F : FilterField > F.greaterOrEqual (value : Any ): Filter <F > =
66- BinaryOperationFilter (FilterOperator .GREATER_OR_EQUAL , this , value)
71+ @StreamPublishedApi
72+ public fun <M , F : FilterField <M >> F.greaterOrEqual (value : Any ): Filter <M , F > =
73+ BinaryOperationFilter (BinaryOperator .GREATER_OR_EQUAL , this , value)
6774
6875/* *
6976 * Creates a filter that checks if this field is less than a specific value.
7077 *
7178 * @param value The value to check against.
7279 * @return A filter that matches when this field is less than the specified value.
7380 */
74- public fun <F : FilterField > F.less (value : Any ): Filter <F > =
75- BinaryOperationFilter (FilterOperator .LESS , this , value)
81+ @StreamPublishedApi
82+ public fun <M , F : FilterField <M >> F.less (value : Any ): Filter <M , F > =
83+ BinaryOperationFilter (BinaryOperator .LESS , this , value)
7684
7785/* *
7886 * Creates a filter that checks if this field is less than or equal to a specific value.
7987 *
8088 * @param value The value to check against.
8189 * @return A filter that matches when this field is less than or equal to the specified value.
8290 */
83- public fun <F : FilterField > F.lessOrEqual (value : Any ): Filter <F > =
84- BinaryOperationFilter (FilterOperator .LESS_OR_EQUAL , this , value)
91+ @StreamPublishedApi
92+ public fun <M , F : FilterField <M >> F.lessOrEqual (value : Any ): Filter <M , F > =
93+ BinaryOperationFilter (BinaryOperator .LESS_OR_EQUAL , this , value)
8594
8695/* *
8796 * Creates a filter that checks if this field's value is in a specific list of values.
8897 *
8998 * @param values The list of values to check against.
9099 * @return A filter that matches when this field's value is in the specified list.
91100 */
92- public fun <F : FilterField > F .`in` (values : List <Any >): Filter <F > =
93- BinaryOperationFilter (FilterOperator .IN , this , values.toSet())
101+ @StreamPublishedApi
102+ public fun <M , F : FilterField <M >> F .`in` (values : List <Any >): Filter <M , F > =
103+ BinaryOperationFilter (BinaryOperator .IN , this , values.toSet())
94104
95105/* *
96106 * Creates a filter that checks if this field's value is in a specific set of values.
97107 *
98108 * @param values The values to check against.
99109 * @return A filter that matches when this field's value is in the specified values.
100110 */
101- public fun <F : FilterField > F .`in` (vararg values : Any ): Filter <F > =
102- BinaryOperationFilter (FilterOperator .IN , this , values.toSet())
111+ @StreamPublishedApi
112+ public fun <M , F : FilterField <M >> F .`in` (vararg values : Any ): Filter <M , F > =
113+ BinaryOperationFilter (BinaryOperator .IN , this , values.toSet())
103114
104115/* *
105116 * Creates a filter that performs a full-text query on this field.
106117 *
107118 * @param value The query string to search for.
108119 * @return A filter that matches based on the full-text query.
109120 */
110- public fun <F : FilterField > F.query (value : String ): Filter <F > =
111- BinaryOperationFilter (FilterOperator .QUERY , this , value)
121+ @StreamPublishedApi
122+ public fun <M , F : FilterField <M >> F.query (value : String ): Filter <M , F > =
123+ BinaryOperationFilter (BinaryOperator .QUERY , this , value)
112124
113125/* *
114126 * Creates a filter that performs autocomplete matching on this field.
115127 *
116128 * @param value The string to autocomplete against.
117129 * @return A filter that matches based on autocomplete functionality.
118130 */
119- public fun <F : FilterField > F.autocomplete (value : String ): Filter <F > =
120- BinaryOperationFilter (FilterOperator .AUTOCOMPLETE , this , value)
131+ @StreamPublishedApi
132+ public fun <M , F : FilterField <M >> F.autocomplete (value : String ): Filter <M , F > =
133+ BinaryOperationFilter (BinaryOperator .AUTOCOMPLETE , this , value)
121134
122135/* *
123136 * Creates a filter that checks if this field exists.
124137 *
125138 * @return A filter that matches when this field exists.
126139 */
127- public fun <F : FilterField > F.exists (): Filter <F > =
128- BinaryOperationFilter (FilterOperator .EXISTS , this , true )
140+ @StreamPublishedApi
141+ public fun <M , F : FilterField <M >> F.exists (): Filter <M , F > =
142+ BinaryOperationFilter (BinaryOperator .EXISTS , this , true )
129143
130144/* *
131145 * Creates a filter that checks if this field does not exist.
132146 *
133147 * @return A filter that matches when this field does not exist.
134148 */
135- public fun <F : FilterField > F.doesNotExist (): Filter <F > =
136- BinaryOperationFilter (FilterOperator .EXISTS , this , false )
149+ @StreamPublishedApi
150+ public fun <M , F : FilterField <M >> F.doesNotExist (): Filter <M , F > =
151+ BinaryOperationFilter (BinaryOperator .EXISTS , this , false )
137152
138153/* *
139154 * Creates a filter that checks if this field contains a specific value.
140155 *
141156 * @param value The value to check for within this field.
142157 * @return A filter that matches when this field contains the specified value.
143158 */
144- public fun <F : FilterField > F.contains (value : Any ): Filter <F > =
145- BinaryOperationFilter (FilterOperator .CONTAINS , this , value)
159+ @StreamPublishedApi
160+ public fun <M , F : FilterField <M >> F.contains (value : Any ): Filter <M , F > =
161+ BinaryOperationFilter (BinaryOperator .CONTAINS , this , value)
146162
147163/* *
148164 * Creates a filter that checks if a specific path exists within this field.
149165 *
150166 * @param value The path to check for existence.
151167 * @return A filter that matches when the specified path exists in this field.
152168 */
153- public fun <F : FilterField > F.pathExists (value : String ): Filter <F > =
154- BinaryOperationFilter (FilterOperator .PATH_EXISTS , this , value)
169+ @StreamPublishedApi
170+ public fun <M , F : FilterField <M >> F.pathExists (value : String ): Filter <M , F > =
171+ BinaryOperationFilter (BinaryOperator .PATH_EXISTS , this , value)
0 commit comments