class ReactiveContextVariableUtils {



    /**
     * <p>
     *   Lazily resolve the reactive asynchronous object into a {@link Publisher}.
     * </p>
     * <p>
     *   The main aim of this method is to mirror the mechanism used by Spring for resolving
     *   asynchronous variables at the model of views (see Spring's
     *   {@link org.springframework.web.reactive.result.view.ViewResolutionResultHandler}):
     * </p>
     * <ul>
     *     <li>{@code Flux<T>} or other <em>multi-valued</em> streams are resolved as
     *         {@code List<T>} so that they are <em>iterable</em>.</li>
     *     <li>{@code Mono<T>} or other <em>single-valued</em> streams are resolved as
     *         {@code T} so that they are directly referenceable just like any other object.</li>
     * </ul>
     *
     * @param asyncObj the asynchronous object being wrapped by this lazy variable.
     * @param reactiveAdapterRegistry the Spring {@link ReactiveAdapterRegistry}.
     * @return the resolved {@link Publisher}.
     */
    static Publisher<Object> computePublisherValue(
            final Object asyncObj, final ReactiveAdapterRegistry reactiveAdapterRegistry) {<FILL_FUNCTION_BODY>}




    private ReactiveContextVariableUtils() {
        super();
    }

}


        if (asyncObj instanceof Flux<?> || asyncObj instanceof Mono<?>) {
            // If the async object is a Flux or a Mono, we don't need the ReactiveAdapterRegistry (and we allow
            // initialization to happen without the registry, which is not possible with other Publisher<?>
            // implementations.
            return (Publisher<Object>) asyncObj;
        }


        if (reactiveAdapterRegistry == null) {
            throw new IllegalArgumentException(
                    "Could not initialize lazy reactive context variable (data driver or explicitly-set " +
                    "reactive wrapper):  Value is of class " + asyncObj.getClass().getName() +", but no " +
                    "ReactiveAdapterRegistry has been set. This can happen if this context variable is used " +
                    "for rendering a template without going through a " +
                    ThymeleafReactiveView.class.getSimpleName() + " or if there is no " +
                    "ReactiveAdapterRegistry bean registered at the application context. In such cases, it is " +
                    "required that the wrapped lazy variable values are instances of either " +
                    Flux.class.getName() + " or " + Mono.class.getName() + ".");
        }

        final ReactiveAdapter adapter = reactiveAdapterRegistry.getAdapter(null, asyncObj);
        if (adapter != null) {
            final Publisher<Object> publisher = adapter.toPublisher(asyncObj);
            if (adapter.isMultiValue()) {
                return Flux.from(publisher);
            } else {
                return Mono.from(publisher);
            }
        }

        throw new IllegalArgumentException(
                "Reactive context variable (data driver or explicitly-set reactive wrapper) is of " +
                "class " + asyncObj.getClass().getName() +", but the ReactiveAdapterRegistry " +
                "does not contain a valid adapter able to convert it into a supported reactive data stream.");

    
<no_super_class>