public static < T > T convertPublisher ( Object object , Class < T > publisherType ) { Objects . requireNonNull ( object , "Invalid argument [object]: " + object ) ; Objects . requireNonNull ( object , "Invalid argument [publisherType]: " + publisherType ) ; if ( object instanceof CompletableFuture ) { @ SuppressWarnings ( "unchecked" ) Publisher < T > futurePublisher = ( Publisher < T > ) Publishers . fromCompletableFuture ( ( ) -> ( ( CompletableFuture ) object ) ) ; return ConversionService . SHARED . convert ( futurePublisher , publisherType ) . orElseThrow ( ( ) -> new IllegalArgumentException ( "Unsupported Reactive type: " + object . getClass ( ) ) ) ; } else { return ConversionService . SHARED . convert ( object , publisherType ) . orElseThrow ( ( ) -> new IllegalArgumentException ( "Unsupported Reactive type: " + object . getClass ( ) ) ) ; } }
Attempts to convert the publisher to the given type .