Skip to content

Commit b6fe685

Browse files
committed
Fix some Kotlin <-> Java DSL interoperability
* Remove generic argument from the `EnricherSpec.property()` which simply does nothing, but noise - `Object` is enough * Do the same for `EnricherSpec.header()` * Fix `KotlinEnricherSpec`, respectively: no generic argument - just `Any` * Make `KotlinIntegrationFlowDefinition.route()` to expect non-null for `router` arg * Add `& Any` to generic params of the `KotlinRouterSpec` methods - according compiler warning requirements
1 parent abcc115 commit b6fe685

File tree

4 files changed

+14
-18
lines changed

4 files changed

+14
-18
lines changed

spring-integration-core/src/main/java/org/springframework/integration/dsl/EnricherSpec.java

+6-10
Original file line numberDiff line numberDiff line change
@@ -182,11 +182,10 @@ public EnricherSpec shouldClonePayload(boolean shouldClonePayload) {
182182
/**
183183
* @param key the key.
184184
* @param value the value.
185-
* @param <V> the value type.
186185
* @return the enricher spec.
187186
* @see ContentEnricher#setPropertyExpressions(Map)
188187
*/
189-
public <V> EnricherSpec property(String key, V value) {
188+
public EnricherSpec property(String key, Object value) {
190189
this.propertyExpressions.put(key, new ValueExpression<>(value));
191190
return _this();
192191
}
@@ -220,25 +219,23 @@ public <P> EnricherSpec propertyFunction(String key, Function<Message<P>, Object
220219
* Set a header with the value if it is not already present.
221220
* @param name the header name.
222221
* @param value the value.
223-
* @param <V> the value type.
224222
* @return the enricher spec.
225223
* @see ContentEnricher#setHeaderExpressions(Map)
226224
*/
227-
public <V> EnricherSpec header(String name, V value) {
225+
public EnricherSpec header(String name, Object value) {
228226
return header(name, value, null);
229227
}
230228

231229
/**
232230
* @param name the header name.
233231
* @param value the value.
234232
* @param overwrite true to overwrite the header if already present.
235-
* @param <V> the value type.
236233
* @return the enricher spec.
237234
* @see ContentEnricher#setHeaderExpressions(Map)
238235
*/
239-
public <V> EnricherSpec header(String name, V value, @Nullable Boolean overwrite) {
240-
AbstractHeaderValueMessageProcessor<V> headerValueMessageProcessor =
241-
new StaticHeaderValueMessageProcessor<V>(value);
236+
public EnricherSpec header(String name, Object value, @Nullable Boolean overwrite) {
237+
AbstractHeaderValueMessageProcessor<Object> headerValueMessageProcessor =
238+
new StaticHeaderValueMessageProcessor<>(value);
242239
headerValueMessageProcessor.setOverwrite(overwrite);
243240
return header(name, headerValueMessageProcessor);
244241
}
@@ -305,11 +302,10 @@ private EnricherSpec headerExpression(String name, Expression expression, @Nulla
305302
* Set a header value using an explicit {@link HeaderValueMessageProcessor}.
306303
* @param headerName the header name.
307304
* @param headerValueMessageProcessor the headerValueMessageProcessor.
308-
* @param <V> the value type.
309305
* @return the enricher spec.
310306
* @see ContentEnricher#setHeaderExpressions(Map)
311307
*/
312-
public <V> EnricherSpec header(String headerName, HeaderValueMessageProcessor<V> headerValueMessageProcessor) {
308+
public EnricherSpec header(String headerName, HeaderValueMessageProcessor<Object> headerValueMessageProcessor) {
313309
Assert.hasText(headerName, "'headerName' must not be empty");
314310
this.headerExpressions.put(headerName, headerValueMessageProcessor);
315311
return _this();

spring-integration-core/src/main/kotlin/org/springframework/integration/dsl/KotlinEnricherSpec.kt

+3-3
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class KotlinEnricherSpec(override val delegate: EnricherSpec)
8585
this.delegate.shouldClonePayload(shouldClonePayload)
8686
}
8787

88-
fun <V> property(key: String, value: V) {
88+
fun property(key: String, value: Any) {
8989
this.delegate.property(key, value)
9090
}
9191

@@ -97,7 +97,7 @@ class KotlinEnricherSpec(override val delegate: EnricherSpec)
9797
this.delegate.propertyFunction(key, function)
9898
}
9999

100-
fun <V> header(name: String, value: V, overwrite: Boolean?) {
100+
fun header(name: String, value: Any, overwrite: Boolean?) {
101101
this.delegate.header(name, value, overwrite)
102102
}
103103

@@ -109,7 +109,7 @@ class KotlinEnricherSpec(override val delegate: EnricherSpec)
109109
this.delegate.header(name, function, overwrite)
110110
}
111111

112-
fun <V> header(headerName: String, headerValueMessageProcessor: HeaderValueMessageProcessor<V>) {
112+
fun header(headerName: String, headerValueMessageProcessor: HeaderValueMessageProcessor<Any>) {
113113
this.delegate.header(headerName, headerValueMessageProcessor)
114114
}
115115

spring-integration-core/src/main/kotlin/org/springframework/integration/dsl/KotlinIntegrationFlowDefinition.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1043,7 +1043,7 @@ class KotlinIntegrationFlowDefinition(@PublishedApi internal val delegate: Integ
10431043
* current integration flow position.
10441044
* In addition, accept options for the integration endpoint using [GenericEndpointSpec].
10451045
*/
1046-
fun <R : AbstractMessageRouter?> route(router: R, endpointConfigurer: GenericEndpointSpec<R>.() -> Unit = {}) {
1046+
fun <R : AbstractMessageRouter> route(router: R, endpointConfigurer: GenericEndpointSpec<R>.() -> Unit = {}) {
10471047
this.delegate.route(router, endpointConfigurer)
10481048
}
10491049

spring-integration-core/src/main/kotlin/org/springframework/integration/dsl/KotlinRouterSpec.kt

+4-4
Original file line numberDiff line numberDiff line change
@@ -51,19 +51,19 @@ class KotlinRouterSpec<K, R : AbstractMappingMessageRouter>(override val delegat
5151
this.delegate.channelKeyFallback(channelKeyFallback)
5252
}
5353

54-
fun channelMapping(key: K, channelName: String) {
54+
fun channelMapping(key: K & Any, channelName: String) {
5555
this.delegate.channelMapping(key, channelName)
5656
}
5757

58-
fun channelMapping(key: K, channel: MessageChannel) {
58+
fun channelMapping(key: K & Any, channel: MessageChannel) {
5959
this.delegate.channelMapping(key, channel)
6060
}
6161

62-
fun subFlowMapping(key: K, subFlow: KotlinIntegrationFlowDefinition.() -> Unit) {
62+
fun subFlowMapping(key: K & Any, subFlow: KotlinIntegrationFlowDefinition.() -> Unit) {
6363
subFlowMapping(key) { definition -> subFlow(KotlinIntegrationFlowDefinition(definition)) }
6464
}
6565

66-
fun subFlowMapping(key: K, subFlow: IntegrationFlow) {
66+
fun subFlowMapping(key: K & Any, subFlow: IntegrationFlow) {
6767
this.delegate.subFlowMapping(key, subFlow)
6868
}
6969

0 commit comments

Comments
 (0)