@@ -136,66 +136,111 @@ public fun <T> CoroutineScope.mono(
136
136
): Mono <T > = monoInternal(this , context, block)
137
137
138
138
/* *
139
- * This function is deprecated in favor of [Mono.awaitSingle].
140
- * Both functions await the first value, or throw [NoSuchElementException] if there is none, but the name
141
- * [Mono.awaitSingle] better reflects the semantics of [Mono].
139
+ * This is a lint function that was added already deprecated in order to guard against confusing usages on [Mono].
140
+ * On [Publisher] instances other than [Mono], this function is not deprecated.
141
+ *
142
+ * Both [awaitFirst] and [awaitSingle] await the first value, or throw [NoSuchElementException] if there is none, but
143
+ * the name [Mono.awaitSingle] better reflects the semantics of [Mono].
144
+ *
145
+ * For example, consider this code:
146
+ * ```
147
+ * myDbClient.findById(uniqueId).awaitFirst() // findById returns a `Mono`
148
+ * ```
149
+ * It looks like more than one value could be returned from `findById` and [awaitFirst] discards the extra elements,
150
+ * when in fact, at most a single value can be present.
142
151
*/
143
152
@Deprecated(
144
153
message = " Mono produces at most one value, so the semantics of dropping the remaining elements are not useful. " +
145
154
" Please use awaitSingle() instead." ,
146
155
level = DeprecationLevel .WARNING ,
147
156
replaceWith = ReplaceWith (" this.awaitSingle()" )
148
- ) // Warning since 1.5, error in 1.6, hidden in 1.7
157
+ ) // Warning since 1.5, error in 1.6
149
158
public suspend fun <T > Mono<T>.awaitFirst (): T = awaitSingle()
150
159
151
160
/* *
152
- * This function is deprecated in favor of [Mono.awaitSingleOrNull].
153
- * Both functions await the first value or return some special value if there is none, but the name
154
- * [Mono.awaitSingleOrNull] better reflects the semantics of [Mono] than an operation with a "first" in its name.
161
+ * This is a lint function that was added already deprecated in order to guard against confusing usages on [Mono].
162
+ * On [Publisher] instances other than [Mono], this function is not deprecated.
163
+ *
164
+ * Both [awaitFirstOrDefault] and [awaitSingleOrNull] await the first value, or return some special value if there
165
+ * is none, but the name [Mono.awaitSingleOrNull] better reflects the semantics of [Mono].
166
+ *
167
+ * For example, consider this code:
168
+ * ```
169
+ * myDbClient.findById(uniqueId).awaitFirstOrDefault(default) // findById returns a `Mono`
170
+ * ```
171
+ * It looks like more than one value could be returned from `findById` and [awaitFirstOrDefault] discards the extra
172
+ * elements, when in fact, at most a single value can be present.
155
173
*/
156
174
@Deprecated(
157
175
message = " Mono produces at most one value, so the semantics of dropping the remaining elements are not useful. " +
158
176
" Please use awaitSingleOrNull() instead." ,
159
177
level = DeprecationLevel .WARNING ,
160
178
replaceWith = ReplaceWith (" this.awaitSingleOrNull() ?: default" )
161
- ) // Warning since 1.5, error in 1.6, hidden in 1.7
179
+ ) // Warning since 1.5, error in 1.6
162
180
public suspend fun <T > Mono<T>.awaitFirstOrDefault (default : T ): T = awaitSingleOrNull() ? : default
163
181
164
182
/* *
165
- * This function is deprecated in favor of [Mono.awaitSingleOrNull].
166
- * Both functions await the first value or return some special value if there is none, but the name
167
- * [Mono.awaitSingleOrNull] better reflects the semantics of [Mono].
183
+ * This is a lint function that was added already deprecated in order to guard against confusing usages on [Mono].
184
+ * On [Publisher] instances other than [Mono], this function is not deprecated.
185
+ *
186
+ * Both [awaitFirstOrNull] and [awaitSingleOrNull] await the first value, or return some special value if there
187
+ * is none, but the name [Mono.awaitSingleOrNull] better reflects the semantics of [Mono].
188
+ *
189
+ * For example, consider this code:
190
+ * ```
191
+ * myDbClient.findById(uniqueId).awaitFirstOrNull() // findById returns a `Mono`
192
+ * ```
193
+ * It looks like more than one value could be returned from `findById` and [awaitFirstOrNull] discards the extra
194
+ * elements, when in fact, at most a single value can be present.
168
195
*/
169
196
@Deprecated(
170
197
message = " Mono produces at most one value, so the semantics of dropping the remaining elements are not useful. " +
171
198
" Please use awaitSingleOrNull() instead." ,
172
199
level = DeprecationLevel .WARNING ,
173
200
replaceWith = ReplaceWith (" this.awaitSingleOrNull()" )
174
- ) // Warning since 1.5, error in 1.6, hidden in 1.7
201
+ ) // Warning since 1.5, error in 1.6
175
202
public suspend fun <T > Mono<T>.awaitFirstOrNull (): T ? = awaitSingleOrNull()
176
203
177
204
/* *
178
- * This function is deprecated in favor of [Mono.awaitSingleOrNull].
179
- * Both functions await the first value or return some special value if there is none, but the name
180
- * [Mono.awaitSingleOrNull] better reflects the semantics of [Mono] than an operation with a "first" in its name.
205
+ * This is a lint function that was added already deprecated in order to guard against confusing usages on [Mono].
206
+ * On [Publisher] instances other than [Mono], this function is not deprecated.
207
+ *
208
+ * Both [awaitFirstOrElse] and [awaitSingleOrNull] await the first value, or return some special value if there
209
+ * is none, but the name [Mono.awaitSingleOrNull] better reflects the semantics of [Mono].
210
+ *
211
+ * For example, consider this code:
212
+ * ```
213
+ * myDbClient.findById(uniqueId).awaitFirstOrElse(defaultValue) // findById returns a `Mono`
214
+ * ```
215
+ * It looks like more than one value could be returned from `findById` and [awaitFirstOrElse] discards the extra
216
+ * elements, when in fact, at most a single value can be present.
181
217
*/
182
218
@Deprecated(
183
219
message = " Mono produces at most one value, so the semantics of dropping the remaining elements are not useful. " +
184
220
" Please use awaitSingleOrNull() instead." ,
185
221
level = DeprecationLevel .WARNING ,
186
222
replaceWith = ReplaceWith (" this.awaitSingleOrNull() ?: defaultValue()" )
187
- ) // Warning since 1.5, error in 1.6, hidden in 1.7
223
+ ) // Warning since 1.5, error in 1.6
188
224
public suspend fun <T > Mono<T>.awaitFirstOrElse (defaultValue : () -> T ): T = awaitSingleOrNull() ? : defaultValue()
189
225
190
226
/* *
191
- * This function is deprecated in favor of [Mono.awaitSingle].
192
- * Both functions await the only value or return some special value if there is none, but the name
193
- * "awaitLast" strongly suggests that there is more than one value, which is not the case.
227
+ * This is a lint function that was added already deprecated in order to guard against confusing usages on [Mono].
228
+ * On [Publisher] instances other than [Mono], this function is not deprecated.
229
+ *
230
+ * Both [awaitLast] and [awaitSingle] await the single value, or throw [NoSuchElementException] if there is none, but
231
+ * the name [Mono.awaitSingle] better reflects the semantics of [Mono].
232
+ *
233
+ * For example, consider this code:
234
+ * ```
235
+ * myDbClient.findById(uniqueId).awaitLast() // findById returns a `Mono`
236
+ * ```
237
+ * It looks like more than one value could be returned from `findById` and [awaitLast] discards the initial elements,
238
+ * when in fact, at most a single value can be present.
194
239
*/
195
240
@Deprecated(
196
241
message = " Mono produces at most one value, so the last element is the same as the first. " +
197
242
" Please use awaitSingle() instead." ,
198
243
level = DeprecationLevel .WARNING ,
199
244
replaceWith = ReplaceWith (" this.awaitSingle()" )
200
- ) // Warning since 1.5, error in 1.6, hidden in 1.7
245
+ ) // Warning since 1.5, error in 1.6
201
246
public suspend fun <T > Mono<T>.awaitLast (): T = awaitSingle()
0 commit comments