@@ -21,7 +21,7 @@ package reactor.core.scala.publisher
2121import java .lang .{Boolean => JBoolean , Iterable => JIterable , Long => JLong }
2222import java .time .{Duration => JDuration }
2323import java .util .concurrent .{Callable , CompletableFuture }
24- import java .util .function .{BiConsumer , BiFunction , Consumer , Function , Predicate , Supplier }
24+ import java .util .function .{BiConsumer , BiFunction , BiPredicate , Consumer , Function , Predicate , Supplier }
2525import java .util .logging .Level
2626
2727import org .reactivestreams .{Publisher , Subscriber , Subscription }
@@ -1397,12 +1397,55 @@ object Mono {
13971397 * the type of items emitted by each Publisher
13981398 * @return a Mono that emits a Boolean value that indicates whether the two sequences are the same
13991399 */
1400- def sequenceEqual [T ](source1 : Publisher [_ <: T ], source2 : Publisher [_ <: T ]) = Mono [Boolean ](
1400+ def sequenceEqual [T ](source1 : Publisher [_ <: T ], source2 : Publisher [_ <: T ]): Mono [ Boolean ] = Mono [Boolean ](
14011401 JMono .sequenceEqual[T ](source1, source2).map(new Function [JBoolean , Boolean ] {
14021402 override def apply (t : JBoolean ) = Boolean2boolean (t)
14031403 })
14041404 )
14051405
1406+ /**
1407+ * Returns a Mono that emits a Boolean value that indicates whether two Publisher sequences are the
1408+ * same by comparing the items emitted by each Publisher pairwise based on the results of a specified
1409+ * equality function.
1410+ *
1411+ * @param source1
1412+ * the first Publisher to compare
1413+ * @param source2
1414+ * the second Publisher to compare
1415+ * @param isEqual
1416+ * a function used to compare items emitted by each Publisher
1417+ * @tparam T
1418+ * the type of items emitted by each Publisher
1419+ * @return a Mono that emits a Boolean value that indicates whether the two sequences are the same
1420+ */
1421+ def sequenceEqual [T ](source1 : Publisher [_ <: T ], source2 : Publisher [_ <: T ], isEqual : (T , T ) => Boolean ): Mono [Boolean ] = {
1422+ Mono (JMono .sequenceEqual[T ](source1, source2, new BiPredicate [T , T ] {
1423+ override def test (t : T , u : T ): Boolean = isEqual(t, u)
1424+ })).map(Boolean2boolean )
1425+ }
1426+
1427+ /**
1428+ * Returns a Mono that emits a Boolean value that indicates whether two Publisher sequences are the
1429+ * same by comparing the items emitted by each Publisher pairwise based on the results of a specified
1430+ * equality function.
1431+ *
1432+ * @param source1
1433+ * the first Publisher to compare
1434+ * @param source2
1435+ * the second Publisher to compare
1436+ * @param isEqual
1437+ * a function used to compare items emitted by each Publisher
1438+ * @param bufferSize
1439+ * the number of items to prefetch from the first and second source Publisher
1440+ * @tparam T
1441+ * the type of items emitted by each Publisher
1442+ * @return a Mono that emits a Boolean value that indicates whether the two Publisher two sequences
1443+ * are the same according to the specified function
1444+ */
1445+ def sequenceEqual [T ](source1 : Publisher [_ <: T ], source2 : Publisher [_ <: T ], isEqual : (T , T ) => Boolean , bufferSize : Int ): Mono [Boolean ] = Mono (JMono .sequenceEqual[T ](source1, source2, new BiPredicate [T , T ] {
1446+ override def test (t : T , u : T ): Boolean = isEqual(t, u)
1447+ }, bufferSize)).map(Boolean2boolean )
1448+
14061449 /**
14071450 * Merge given monos into a new a `Mono` that will be fulfilled when all of the given `Monos`
14081451 * have been fulfilled. An error will cause pending results to be cancelled and immediate error emission to the
0 commit comments