diff --git a/spring-core/src/main/java/org/springframework/core/ReactiveAdapter.java b/spring-core/src/main/java/org/springframework/core/ReactiveAdapter.java
index bb0b7ad72a..a829562f2d 100644
--- a/spring-core/src/main/java/org/springframework/core/ReactiveAdapter.java
+++ b/spring-core/src/main/java/org/springframework/core/ReactiveAdapter.java
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package org.springframework.core;
import org.reactivestreams.Publisher;
@@ -22,8 +23,8 @@ import reactor.core.publisher.Mono;
/**
* Contract for adapting to and from {@link Flux} and {@link Mono}.
*
- *
An adapter supports a specific adaptee type whose stream semantics can be
- * checked via {@link #getDescriptor()}.
+ *
An adapter supports a specific adaptee type whose stream semantics
+ * can be checked via {@link #getDescriptor()}.
*
*
Use the {@link ReactiveAdapterRegistry} to obtain an adapter for a
* supported adaptee type or to register additional adapters.
@@ -78,14 +79,12 @@ public interface ReactiveAdapter {
private final boolean isNoValue;
-
public Descriptor(boolean isMultiValue, boolean canBeEmpty, boolean isNoValue) {
this.isMultiValue = isMultiValue;
this.supportsEmpty = canBeEmpty;
this.isNoValue = isNoValue;
}
-
/**
* Return {@code true} if the adaptee implies 0..N values can be produced
* and is therefore a good fit to adapt to {@link Flux}. A {@code false}
@@ -110,7 +109,6 @@ public interface ReactiveAdapter {
public boolean isNoValue() {
return this.isNoValue;
}
-
}
}
diff --git a/spring-core/src/main/java/org/springframework/core/ReactiveAdapterRegistry.java b/spring-core/src/main/java/org/springframework/core/ReactiveAdapterRegistry.java
index 921dae625f..06d9edeba0 100644
--- a/spring-core/src/main/java/org/springframework/core/ReactiveAdapterRegistry.java
+++ b/spring-core/src/main/java/org/springframework/core/ReactiveAdapterRegistry.java
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package org.springframework.core;
import java.util.LinkedHashMap;
@@ -30,7 +31,6 @@ import rx.Completable;
import rx.Observable;
import rx.Single;
-import org.springframework.core.ReactiveAdapter.Descriptor;
import org.springframework.util.ClassUtils;
/**
@@ -48,29 +48,25 @@ public class ReactiveAdapterRegistry {
private static final boolean rxJava1Present =
ClassUtils.isPresent("rx.Observable", ReactiveAdapterRegistry.class.getClassLoader());
-
- private final Map, ReactiveAdapter> adapterMap = new LinkedHashMap<>();
+ private final Map, ReactiveAdapter> adapterMap = new LinkedHashMap<>(4);
/**
* Create a registry and auto-register default adapters.
*/
public ReactiveAdapterRegistry() {
-
// Flux and Mono ahead of Publisher...
registerMonoAdapter(Mono.class,
- source -> (Mono>) source, source -> source, new Descriptor(false, true, false));
-
+ source -> (Mono>) source, source -> source,
+ new ReactiveAdapter.Descriptor(false, true, false));
registerFluxAdapter(
Flux.class, source -> (Flux>) source, source -> source);
-
registerFluxAdapter(
Publisher.class, source -> Flux.from((Publisher>) source), source -> source);
registerMonoAdapter(CompletableFuture.class,
- source -> Mono.fromFuture((CompletableFuture>) source),
- source -> Mono.from((Publisher>) source).toFuture(),
- new Descriptor(false, true, false)
+ source -> Mono.fromFuture((CompletableFuture>) source), Mono::toFuture,
+ new ReactiveAdapter.Descriptor(false, true, false)
);
if (rxJava1Present) {
@@ -84,9 +80,8 @@ public class ReactiveAdapterRegistry {
* functions can assume that input will never be {@code null} and also that
* any {@link Optional} wrapper is unwrapped.
*/
- public void registerMonoAdapter(Class> adapteeType,
- Function