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