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

io.smallrye.mutiny.converters.uni.ToSingleWithDefault Maven / Gradle / Ivy

package io.smallrye.mutiny.converters.uni;

import java.util.function.Function;

import io.reactivex.Single;
import io.smallrye.mutiny.Uni;

public class ToSingleWithDefault implements Function, Single> {

    private T defaultValue;

    public ToSingleWithDefault(T defaultValue) {
        this.defaultValue = defaultValue;
    }

    @Override
    public Single apply(Uni uni) {
        return Single.fromPublisher(uni.onItem().ifNull().continueWith(defaultValue).convert().toPublisher());
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy