Package org.springframework.core
Class ReactiveTypeDescriptor
- java.lang.Object
- org.springframework.core.ReactiveTypeDescriptor
public final class ReactiveTypeDescriptor extends Object
Describes the semantics of a reactive type including boolean checks forisMultiValue()
,isNoValue()
, andsupportsEmpty()
.- Since:
- 5.0
- Author:
- Rossen Stoyanchev
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object other)
Object
getEmptyValue()
Return an empty-value instance for the underlying reactive or async type.Class<?>
getReactiveType()
Return the reactive type for this descriptor.int
hashCode()
boolean
isDeferred()
Whether the underlying operation is deferred and needs to be started explicitly, e.g.boolean
isMultiValue()
Returntrue
if the reactive type can produce more than 1 value can be produced and is therefore a good fit to adapt toFlux
.boolean
isNoValue()
Returntrue
if the reactive type does not produce any values and only provides completion and error signals.static ReactiveTypeDescriptor
multiValue(Class<?> type, Supplier<?> emptySupplier)
Descriptor for a reactive type that can produce 0..N values.static ReactiveTypeDescriptor
nonDeferredAsyncValue(Class<?> type, Supplier<?> emptySupplier)
The same assingleOptionalValue(Class, Supplier)
but for a non-deferred, async type such asCompletableFuture
.static ReactiveTypeDescriptor
noValue(Class<?> type, Supplier<?> emptySupplier)
Descriptor for a reactive type that does not produce any values.static ReactiveTypeDescriptor
singleOptionalValue(Class<?> type, Supplier<?> emptySupplier)
Descriptor for a reactive type that can produce 0..1 values.static ReactiveTypeDescriptor
singleRequiredValue(Class<?> type)
Descriptor for a reactive type that must produce 1 value to complete.boolean
supportsEmpty()
Returntrue
if the reactive type can complete with no values.
Method Detail
getReactiveType
public Class<?> getReactiveType()
Return the reactive type for this descriptor.
isMultiValue
public boolean isMultiValue()
Returntrue
if the reactive type can produce more than 1 value can be produced and is therefore a good fit to adapt toFlux
. Afalse
return value implies the reactive type can produce 1 value at most and is therefore a good fit to adapt toMono
.
isNoValue
public boolean isNoValue()
Returntrue
if the reactive type does not produce any values and only provides completion and error signals.
supportsEmpty
public boolean supportsEmpty()
Returntrue
if the reactive type can complete with no values.
getEmptyValue
public Object getEmptyValue()
Return an empty-value instance for the underlying reactive or async type. Use of this type impliessupportsEmpty()
is true.
isDeferred
public boolean isDeferred()
Whether the underlying operation is deferred and needs to be started explicitly, e.g. via subscribing (or similar), or whether it is triggered without the consumer having any control.- Since:
- 5.2.7
multiValue
public static ReactiveTypeDescriptor multiValue(Class<?> type, Supplier<?> emptySupplier)
Descriptor for a reactive type that can produce 0..N values.- Parameters:
type
- the reactive typeemptySupplier
- a supplier of an empty-value instance of the reactive type
singleOptionalValue
public static ReactiveTypeDescriptor singleOptionalValue(Class<?> type, Supplier<?> emptySupplier)
Descriptor for a reactive type that can produce 0..1 values.- Parameters:
type
- the reactive typeemptySupplier
- a supplier of an empty-value instance of the reactive type
singleRequiredValue
public static ReactiveTypeDescriptor singleRequiredValue(Class<?> type)
Descriptor for a reactive type that must produce 1 value to complete.- Parameters:
type
- the reactive type
noValue
public static ReactiveTypeDescriptor noValue(Class<?> type, Supplier<?> emptySupplier)
Descriptor for a reactive type that does not produce any values.- Parameters:
type
- the reactive typeemptySupplier
- a supplier of an empty-value instance of the reactive type
nonDeferredAsyncValue
public static ReactiveTypeDescriptor nonDeferredAsyncValue(Class<?> type, Supplier<?> emptySupplier)
The same assingleOptionalValue(Class, Supplier)
but for a non-deferred, async type such asCompletableFuture
.- Parameters:
type
- the reactive typeemptySupplier
- a supplier of an empty-value instance of the reactive type- Since:
- 5.2.7