All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.neo4j.driver.internal.shaded.reactor.core.publisher.FluxExtensions.kt Maven / Gradle / Ivy

There is a newer version: 5.21.0
Show newest version
/*
 * Copyright (c) 2011-2021 VMware Inc. or its affiliates, All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

@file:Suppress("DEPRECATION")

package reactor.core.publisher

import org.reactivestreams.Publisher
import java.util.stream.Stream
import kotlin.reflect.KClass


/**
 * Extension to convert any [Publisher] of [T] to a [Flux].
 *
 * Note this extension doesn't make much sense on a [Flux] but it won't be converted so it
 * doesn't hurt.
 *
 * @author Simon Baslé
 * @since 3.1.1
 */
@Deprecated("To be removed in 3.3.0.RELEASE, replaced by module reactor-kotlin-extensions",
        ReplaceWith("toFlux()", "reactor.kotlin.core.publisher.toFlux"))
fun  Publisher.toFlux(): Flux = Flux.from(this)

/**
 * Extension for transforming an [Iterator] to a [Flux].
 *
 * @author Sebastien Deleuze
 * @since 3.1
 */
@Deprecated("To be removed in 3.3.0.RELEASE, replaced by module reactor-kotlin-extensions",
        ReplaceWith("toFlux()", "reactor.kotlin.core.publisher.toFlux"))
fun  Iterator.toFlux(): Flux = toIterable().toFlux()

/**
 * Extension for transforming an [Iterable] to a [Flux].
 *
 * @author Sebastien Deleuze
 * @since 3.1
 */
@Deprecated("To be removed in 3.3.0.RELEASE, replaced by module reactor-kotlin-extensions",
        ReplaceWith("toFlux()", "reactor.kotlin.core.publisher.toFlux"))
fun  Iterable.toFlux(): Flux = Flux.fromIterable(this)

/**
 * Extension for transforming a [Sequence] to a [Flux].
 *
 * @author Sebastien Deleuze
 * @since 3.1
 */
@Deprecated("To be removed in 3.3.0.RELEASE, replaced by module reactor-kotlin-extensions",
        ReplaceWith("toFlux()", "reactor.kotlin.core.publisher.toFlux"))
fun  Sequence.toFlux(): Flux = Flux.fromIterable(object : Iterable {
    override fun iterator(): Iterator = [email protected]()
})

/**
 * Extension for transforming a [Stream] to a [Flux].
 *
 * @author Sebastien Deleuze
 * @since 3.1
 */
@Deprecated("To be removed in 3.3.0.RELEASE, replaced by module reactor-kotlin-extensions",
        ReplaceWith("toFlux()", "reactor.kotlin.core.publisher.toFlux"))
fun  Stream.toFlux(): Flux = Flux.fromStream(this)

/**
 * Extension for transforming a [BooleanArray] to a [Flux].
 *
 * @author Sebastien Deleuze
 * @since 3.1
 */
@Deprecated("To be removed in 3.3.0.RELEASE, replaced by module reactor-kotlin-extensions",
        ReplaceWith("toFlux()", "reactor.kotlin.core.publisher.toFlux"))
fun BooleanArray.toFlux(): Flux = this.toList().toFlux()

/**
 * Extension for transforming a [ByteArray] to a [Flux].
 *
 * @author Sebastien Deleuze
 * @since 3.1
 */
@Deprecated("To be removed in 3.3.0.RELEASE, replaced by module reactor-kotlin-extensions",
        ReplaceWith("toFlux()", "reactor.kotlin.core.publisher.toFlux"))
fun ByteArray.toFlux(): Flux = this.toList().toFlux()

/**
 * Extension for transforming a [ShortArray] to a [Flux].
 *
 * @author Sebastien Deleuze
 * @since 3.1
 */
@Deprecated("To be removed in 3.3.0.RELEASE, replaced by module reactor-kotlin-extensions",
        ReplaceWith("toFlux()", "reactor.kotlin.core.publisher.toFlux"))
fun ShortArray.toFlux(): Flux = this.toList().toFlux()

/**
 * Extension for transforming a [IntArray] to a [Flux].
 *
 * @author Sebastien Deleuze
 * @since 3.1
 */
@Deprecated("To be removed in 3.3.0.RELEASE, replaced by module reactor-kotlin-extensions",
        ReplaceWith("toFlux()", "reactor.kotlin.core.publisher.toFlux"))
fun IntArray.toFlux(): Flux = this.toList().toFlux()

/**
 * Extension for transforming a [LongArray] to a [Flux].
 *
 * @author Sebastien Deleuze
 * @since 3.1
 */
@Deprecated("To be removed in 3.3.0.RELEASE, replaced by module reactor-kotlin-extensions",
        ReplaceWith("toFlux()", "reactor.kotlin.core.publisher.toFlux"))
fun LongArray.toFlux(): Flux = this.toList().toFlux()

/**
 * Extension for transforming a [FloatArray] to a [Flux].
 *
 * @author Sebastien Deleuze
 * @since 3.1
 */
@Deprecated("To be removed in 3.3.0.RELEASE, replaced by module reactor-kotlin-extensions",
        ReplaceWith("toFlux()", "reactor.kotlin.core.publisher.toFlux"))
fun FloatArray.toFlux(): Flux = this.toList().toFlux()

/**
 * Extension for transforming a [DoubleArray] to a [Flux].
 *
 * @author Sebastien Deleuze
 * @since 3.1
 */
@Deprecated("To be removed in 3.3.0.RELEASE, replaced by module reactor-kotlin-extensions",
        ReplaceWith("toFlux()", "reactor.kotlin.core.publisher.toFlux"))
fun DoubleArray.toFlux(): Flux = this.toList().toFlux()

/**
 * Extension for transforming an [Array] to a [Flux].
 *
 * @author Sebastien Deleuze
 * @since 3.1
 */
@Deprecated("To be removed in 3.3.0.RELEASE, replaced by module reactor-kotlin-extensions",
        ReplaceWith("toFlux()", "reactor.kotlin.core.publisher.toFlux"))
fun  Array.toFlux(): Flux = Flux.fromArray(this)

private fun  Iterator.toIterable() = object : Iterable {
    override fun iterator(): Iterator = this@toIterable
}

/**
 * Extension for transforming an exception to a [Flux] that completes with the specified error.
 *
 * @author Sebastien Deleuze
 * @since 3.1
 */
@Deprecated("To be removed in 3.3.0.RELEASE, replaced by module reactor-kotlin-extensions",
        ReplaceWith("toFlux()", "reactor.kotlin.core.publisher.toFlux"))
fun  Throwable.toFlux(): Flux = Flux.error(this)

/**
 * Extension for [Flux.cast] providing a `cast()` variant.
 *
 * @author Sebastien Deleuze
 * @since 3.1
 */
@Deprecated("To be removed in 3.3.0.RELEASE, replaced by module reactor-kotlin-extensions",
        ReplaceWith("cast()", "reactor.kotlin.core.publisher.cast"))
inline fun  Flux<*>.cast(): Flux = cast(T::class.java)


/**
 * Extension for [Flux.doOnError] providing a [KClass] based variant.
 *
 * @author Sebastien Deleuze
 * @since 3.1
 */
@Deprecated("To be removed in 3.3.0.RELEASE, replaced by module reactor-kotlin-extensions",
        ReplaceWith("doOnError(exceptionType, onError)", "reactor.kotlin.core.publisher.doOnError"))
fun  Flux.doOnError(exceptionType: KClass, onError: (E) -> Unit): Flux =
        doOnError(exceptionType.java) { onError(it) }

/**
 * Extension for [Flux.onErrorMap] providing a [KClass] based variant.
 *
 * @author Sebastien Deleuze
 * @since 3.1
 */
@Deprecated("To be removed in 3.3.0.RELEASE, replaced by module reactor-kotlin-extensions",
        ReplaceWith("onErrorMap(exceptionType, mapper)", "reactor.kotlin.core.publisher.onErrorMap"))
fun  Flux.onErrorMap(exceptionType: KClass, mapper: (E) -> Throwable): Flux =
        onErrorMap(exceptionType.java) { mapper(it) }

/**
 * Extension for [Flux.ofType] providing a `ofType()` variant.
 *
 * @author Sebastien Deleuze
 * @since 3.1
 */
@Deprecated("To be removed in 3.3.0.RELEASE, replaced by module reactor-kotlin-extensions",
        ReplaceWith("ofType()", "reactor.kotlin.core.publisher.ofType"))
inline fun  Flux<*>.ofType(): Flux = ofType(T::class.java)

/**
 * Extension for [Flux.onErrorResume] providing a [KClass] based variant.
 *
 * @author Sebastien Deleuze
 * @since 3.1
 */
@Deprecated("To be removed in 3.3.0.RELEASE, replaced by module reactor-kotlin-extensions",
        ReplaceWith("onErrorResume(exceptionType, fallback)", "reactor.kotlin.core.publisher.onErrorResume"))
fun  Flux.onErrorResume(exceptionType: KClass, fallback: (E) -> Publisher): Flux =
        onErrorResume(exceptionType.java) { fallback(it) }

/**
 * Extension for [Flux.onErrorReturn] providing a [KClass] based variant.
 *
 * @author Sebastien Deleuze
 * @since 3.1
 */
@Deprecated("To be removed in 3.3.0.RELEASE, replaced by module reactor-kotlin-extensions",
        ReplaceWith("onErrorReturn(exceptionType, value)", "reactor.kotlin.core.publisher.onErrorReturn"))
fun  Flux.onErrorReturn(exceptionType: KClass, value: T): Flux =
        onErrorReturn(exceptionType.java, value)

/**
 * Extension for flattening [Flux] of [Iterable]
 *
 * @author Igor Perikov
 * @since 3.1
 */
@Deprecated("To be removed in 3.3.0.RELEASE, replaced by module reactor-kotlin-extensions",
        ReplaceWith("split()", "reactor.kotlin.core.publisher.split"))
fun  Flux>.split(): Flux = this.flatMapIterable { it }

/**
 * Extension for [Flux.switchIfEmpty] accepting a function providing a Publisher. This allows having a deferred execution with
 * the [switchIfEmpty] operator
 *
 * @author Kevin Davin
 * @since 3.2
 */
@Deprecated("To be removed in 3.3.0.RELEASE, replaced by module reactor-kotlin-extensions",
        ReplaceWith("switchIfEmpty(s)", "reactor.kotlin.core.publisher.switchIfEmpty"))
fun  Flux.switchIfEmpty(s: () -> Publisher): Flux = this.switchIfEmpty(Flux.defer { s() })




© 2015 - 2024 Weber Informatics LLC | Privacy Policy