Skip to content

Commit fa178c3

Browse files
committed
Fix new Sonar smells
* And more convenient Kotlin methods based on `IntegrationFlow`
1 parent 869c5c7 commit fa178c3

File tree

8 files changed

+48
-16
lines changed

8 files changed

+48
-16
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,9 @@ public HeaderEnricherSpec headerExpressions(Consumer<StringStringMapBuilder> con
258258
* @param overwrite true to overwrite existing headers.
259259
* @return the header enricher spec.
260260
*/
261-
public HeaderEnricherSpec headerExpressions(Consumer<StringStringMapBuilder> configurer, Boolean overwrite) {
261+
public HeaderEnricherSpec headerExpressions(Consumer<StringStringMapBuilder> configurer,
262+
@Nullable Boolean overwrite) {
263+
262264
Assert.notNull(configurer, "'configurer' must not be null");
263265
StringStringMapBuilder builder = new StringStringMapBuilder();
264266
configurer.accept(builder);

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020 the original author or authors.
2+
* Copyright 2020-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -49,7 +49,11 @@ abstract class AbstractKotlinRouterSpec<S : AbstractRouterSpec<S, R>, R : Abstra
4949
}
5050

5151
fun defaultSubFlowMapping(subFlow: KotlinIntegrationFlowDefinition.() -> Unit) {
52-
this.delegate.defaultSubFlowMapping { subFlow(KotlinIntegrationFlowDefinition(it)) }
52+
defaultSubFlowMapping {definition -> subFlow(KotlinIntegrationFlowDefinition(definition)) }
53+
}
54+
55+
fun defaultSubFlowMapping(subFlow: IntegrationFlow) {
56+
this.delegate.defaultSubFlowMapping(subFlow)
5357
}
5458

5559
fun defaultOutputToParentFlow() {

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020 the original author or authors.
2+
* Copyright 2020-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -74,7 +74,11 @@ class KotlinEnricherSpec(val delegate: EnricherSpec)
7474
}
7575

7676
fun requestSubFlow(subFlow: KotlinIntegrationFlowDefinition.() -> Unit) {
77-
this.delegate.requestSubFlow { subFlow(KotlinIntegrationFlowDefinition(it)) }
77+
requestSubFlow {definition -> subFlow(KotlinIntegrationFlowDefinition(definition)) }
78+
}
79+
80+
fun requestSubFlow(subFlow: IntegrationFlow) {
81+
this.delegate.requestSubFlow(subFlow)
7882
}
7983

8084
fun shouldClonePayload(shouldClonePayload: Boolean) {

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020 the original author or authors.
2+
* Copyright 2020-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -48,7 +48,11 @@ class KotlinFilterEndpointSpec(val delegate: FilterEndpointSpec)
4848
}
4949

5050
fun discardFlow(subFlow: KotlinIntegrationFlowDefinition.() -> Unit) {
51-
this.delegate.discardFlow { subFlow(KotlinIntegrationFlowDefinition(it)) }
51+
discardFlow {definition -> subFlow(KotlinIntegrationFlowDefinition(definition)) }
52+
}
53+
54+
fun discardFlow(subFlow: IntegrationFlow) {
55+
this.delegate.discardFlow(subFlow)
5256
}
5357

5458
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -836,7 +836,7 @@ class KotlinIntegrationFlowDefinition(@PublishedApi internal val delegate: Integ
836836
routerConfigurer: KotlinRouterSpec<T, ExpressionEvaluatingRouter>.() -> Unit = {}
837837
) {
838838

839-
this.delegate.route<T>(expression) { routerConfigurer(KotlinRouterSpec(it)) }
839+
this.delegate.route(expression) { routerConfigurer(KotlinRouterSpec(it)) }
840840
}
841841

842842
/**

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

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
package org.springframework.integration.dsl
1818

1919
import org.springframework.expression.Expression
20-
import org.springframework.integration.core.GenericSelector
21-
import org.springframework.integration.core.MessageSelector
2220
import org.springframework.integration.router.RecipientListRouter
2321
import org.springframework.messaging.Message
2422
import org.springframework.messaging.MessageChannel
@@ -77,15 +75,27 @@ class KotlinRecipientListRouterSpec(override val delegate: RecipientListRouterSp
7775
}
7876

7977
fun recipientFlow(subFlow: KotlinIntegrationFlowDefinition.() -> Unit) {
80-
this.delegate.recipientFlow { subFlow(KotlinIntegrationFlowDefinition(it)) }
78+
recipientFlow { definition -> subFlow(KotlinIntegrationFlowDefinition(definition)) }
8179
}
8280

8381
fun recipientFlow(expression: String, subFlow: KotlinIntegrationFlowDefinition.() -> Unit) {
84-
this.delegate.recipientFlow(expression) { subFlow(KotlinIntegrationFlowDefinition(it)) }
82+
recipientFlow(expression) { definition -> subFlow(KotlinIntegrationFlowDefinition(definition)) }
8583
}
8684

8785
fun recipientFlow(expression: Expression, subFlow: KotlinIntegrationFlowDefinition.() -> Unit) {
88-
this.delegate.recipientFlow(expression) { subFlow(KotlinIntegrationFlowDefinition(it)) }
86+
recipientFlow(expression) { definition -> subFlow(KotlinIntegrationFlowDefinition(definition)) }
87+
}
88+
89+
fun recipientFlow(subFlow: IntegrationFlow) {
90+
this.delegate.recipientFlow(subFlow)
91+
}
92+
93+
fun recipientFlow(expression: String, subFlow: IntegrationFlow) {
94+
this.delegate.recipientFlow(expression, subFlow)
95+
}
96+
97+
fun recipientFlow(expression: Expression, subFlow: IntegrationFlow) {
98+
this.delegate.recipientFlow(expression, subFlow)
8999
}
90100

91101
}

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,11 @@ class KotlinRouterSpec<K, R : AbstractMappingMessageRouter>(override val delegat
6060
}
6161

6262
fun subFlowMapping(key: K, subFlow: KotlinIntegrationFlowDefinition.() -> Unit) {
63-
this.delegate.subFlowMapping(key) { subFlow(KotlinIntegrationFlowDefinition(it)) }
63+
subFlowMapping(key) { definition -> subFlow(KotlinIntegrationFlowDefinition(definition)) }
64+
}
65+
66+
fun subFlowMapping(key: K, subFlow: IntegrationFlow) {
67+
this.delegate.subFlowMapping(key, subFlow)
6468
}
6569

6670
}

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020 the original author or authors.
2+
* Copyright 2020-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -48,7 +48,11 @@ class KotlinSplitterEndpointSpec<H : AbstractMessageSplitter>(val delegate: Spli
4848
}
4949

5050
fun discardFlow(discardFlow: KotlinIntegrationFlowDefinition.() -> Unit) {
51-
this.delegate.discardFlow { discardFlow(KotlinIntegrationFlowDefinition(it)) }
51+
discardFlow {definition -> discardFlow(KotlinIntegrationFlowDefinition(definition)) }
52+
}
53+
54+
fun discardFlow(discardFlow: IntegrationFlow) {
55+
this.delegate.discardFlow(discardFlow)
5256
}
5357

5458
}

0 commit comments

Comments
 (0)