Browse Source

Add mutate method to RSocketStrategies

Closes gh-22799
pull/22816/head
Rossen Stoyanchev 6 years ago
parent
commit
60d6b5a922
  1. 11
      spring-messaging/src/main/java/org/springframework/messaging/rsocket/DefaultRSocketStrategies.java
  2. 20
      spring-messaging/src/main/java/org/springframework/messaging/rsocket/RSocketStrategies.java

11
spring-messaging/src/main/java/org/springframework/messaging/rsocket/DefaultRSocketStrategies.java

@ -94,6 +94,17 @@ final class DefaultRSocketStrategies implements RSocketStrategies { @@ -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));

20
spring-messaging/src/main/java/org/springframework/messaging/rsocket/RSocketStrategies.java

@ -105,6 +105,14 @@ public interface RSocketStrategies { @@ -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 { @@ -118,15 +126,15 @@ public interface RSocketStrategies {
Builder encoder(Encoder<?>... encoder);
/**
* Add decoders for de-serializing Objects.
* <p>By default this is empty.
* Access and manipulate the list of configured {@link #encoder encoders}.
*/
Builder decoder(Decoder<?>... decoder);
Builder encoders(Consumer<List<Encoder<?>>> consumer);
/**
* Access and manipulate the list of configured {@link #encoder encoders}.
* Add decoders for de-serializing Objects.
* <p>By default this is empty.
*/
Builder encoders(Consumer<List<Encoder<?>>> consumer);
Builder decoder(Decoder<?>... decoder);
/**
* Access and manipulate the list of configured {@link #encoder decoders}.
@ -137,7 +145,7 @@ public interface RSocketStrategies { @@ -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}.
* <p>By default this {@link ReactiveAdapterRegistry#sharedInstance}.
* <p>By default this {@link ReactiveAdapterRegistry#getSharedInstance()}.
* @param registry the registry to use
*/
Builder reactiveAdapterStrategy(ReactiveAdapterRegistry registry);

Loading…
Cancel
Save