reactor-core/src/main/java/reactor/core/publisher/Mono.java
public final Mono<T> single() {
		if (this instanceof Callable) {
			if (this instanceof Fuseable.ScalarCallable) {
				@SuppressWarnings("unchecked")
				Fuseable.ScalarCallable<T> scalarCallable = (Fuseable.ScalarCallable<T>) this;

				T v;
				try {
					v = scalarCallable.call();
				}
				catch (Exception e) {
					return Mono.error(e);
				}
				if (v == null) {
					return Mono.error(new NoSuchElementException("Source was a (constant) empty"));
				}
				return Mono.just(v);
			}
			@SuppressWarnings("unchecked")
			Callable<T> thiz = (Callable<T>)this;
			return Mono.onAssembly(new MonoCallable<>(thiz));
		}
		return Mono.onAssembly(new MonoSingleMono<>(this));
	}
public final Mono<T> single() {
		if (this instanceof Callable) {
			if (this instanceof Fuseable.ScalarCallable) {
				@SuppressWarnings("unchecked")
				Fuseable.ScalarCallable<T> scalarCallable = (Fuseable.ScalarCallable<T>) this;

				T v;
				try {
					v = scalarCallable.call();
				}
				catch (Exception e) {
					return Mono.error(e);
				}
				if (v == null) {
					return Mono.error(new NoSuchElementException("Source was a (constant) empty"));
				}
				return Mono.just(v);
			}
			@SuppressWarnings("unchecked")
			Callable<T> thiz = (Callable<T>)this;
			return Mono.onAssembly(new MonoCallable<>(thiz));
		}
		return Mono.onAssembly(new MonoSingleMono<>(this));
	}
public final Mono < T > single ( ) { if ( this instanceof Callable ) { if ( this instanceof Fuseable . ScalarCallable ) { @ SuppressWarnings ( "unchecked" ) Fuseable . ScalarCallable < T > scalarCallable = ( Fuseable . ScalarCallable < T > ) this ; T v ; try { v = scalarCallable . call ( ) ; } catch ( Exception e ) { return Mono . error ( e ) ; } if ( v == null ) { return Mono . error ( new NoSuchElementException ( "Source was a (constant) empty" ) ) ; } return Mono . just ( v ) ; } @ SuppressWarnings ( "unchecked" ) Callable < T > thiz = ( Callable < T > ) this ; return Mono . onAssembly ( new MonoCallable <> ( thiz ) ) ; } return Mono . onAssembly ( new MonoSingleMono <> ( this ) ) ; }
Expect exactly one item from this {@link Mono} source or signal
{@link java.util.NoSuchElementException} for an empty source.
<p>
<img class="marble" src="doc-files/marbles/singleForMono.svg" alt="">
<p>
Note Mono doesn't need {@link Flux#single(Object)}, since it is equivalent to
{@link #defaultIfEmpty(Object)} in a {@link Mono}.

@return a {@link Mono} with the single item or an error signal
Expect exactly one item from this { @link Mono } source or signal { @link java . util . NoSuchElementException } for an empty source . <p > <img class = marble src = doc - files / marbles / singleForMono . svg alt = > <p > Note Mono doesn t need { @link Flux#single ( Object ) } since it is equivalent to { @link #defaultIfEmpty ( Object ) } in a { @link Mono } .