diff --git a/spring-messaging/src/main/java/org/springframework/messaging/rsocket/DefaultRSocketStrategies.java b/spring-messaging/src/main/java/org/springframework/messaging/rsocket/DefaultRSocketStrategies.java index 56f50a318b..1de258de66 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/rsocket/DefaultRSocketStrategies.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/rsocket/DefaultRSocketStrategies.java @@ -94,6 +94,17 @@ final class DefaultRSocketStrategies implements RSocketStrategies { private DataBufferFactory dataBufferFactory; + public DefaultRSocketStrategiesBuilder() { + } + + public DefaultRSocketStrategiesBuilder(RSocketStrategies other) { + this.encoders.addAll(other.encoders()); + this.decoders.addAll(other.decoders()); + this.adapterRegistry = other.reactiveAdapterRegistry(); + this.dataBufferFactory = other.dataBufferFactory(); + } + + @Override public Builder encoder(Encoder>... encoders) { this.encoders.addAll(Arrays.asList(encoders)); diff --git a/spring-messaging/src/main/java/org/springframework/messaging/rsocket/RSocketStrategies.java b/spring-messaging/src/main/java/org/springframework/messaging/rsocket/RSocketStrategies.java index f0b6fd3772..9ef05661b7 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/rsocket/RSocketStrategies.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/rsocket/RSocketStrategies.java @@ -105,6 +105,14 @@ public interface RSocketStrategies { return new DefaultRSocketStrategies.DefaultRSocketStrategiesBuilder(); } + /** + * Return a builder to create a new {@link RSocketStrategies} instance + * replicated from the current instance. + */ + default Builder mutate() { + return new DefaultRSocketStrategies.DefaultRSocketStrategiesBuilder(this); + } + /** * The builder options for creating {@code RSocketStrategies}. @@ -118,15 +126,15 @@ public interface RSocketStrategies { Builder encoder(Encoder>... encoder); /** - * Add decoders for de-serializing Objects. - *
By default this is empty.
+ * Access and manipulate the list of configured {@link #encoder encoders}.
*/
- Builder decoder(Decoder>... decoder);
+ Builder encoders(Consumer By default this is empty.
*/
- Builder encoders(Consumer By default this {@link ReactiveAdapterRegistry#sharedInstance}.
+ * By default this {@link ReactiveAdapterRegistry#getSharedInstance()}.
* @param registry the registry to use
*/
Builder reactiveAdapterStrategy(ReactiveAdapterRegistry registry);
>> consumer);
/**
- * Access and manipulate the list of configured {@link #encoder encoders}.
+ * Add decoders for de-serializing Objects.
+ *
>> consumer);
+ Builder decoder(Decoder>... decoder);
/**
* Access and manipulate the list of configured {@link #encoder decoders}.
@@ -137,7 +145,7 @@ public interface RSocketStrategies {
* Configure the registry for reactive type support. This can be used to
* to adapt to, and/or determine the semantics of a given
* {@link org.reactivestreams.Publisher Publisher}.
- *