Fix new Sonar smells

* And more convenient Kotlin methods based on `IntegrationFlow`
This commit is contained in:
abilan
2023-04-16 14:49:45 -04:00
parent 869c5c7088
commit fa178c3da6
8 changed files with 48 additions and 16 deletions

View File

@@ -258,7 +258,9 @@ public class HeaderEnricherSpec extends ConsumerEndpointSpec<HeaderEnricherSpec,
* @param overwrite true to overwrite existing headers.
* @return the header enricher spec.
*/
public HeaderEnricherSpec headerExpressions(Consumer<StringStringMapBuilder> configurer, Boolean overwrite) {
public HeaderEnricherSpec headerExpressions(Consumer<StringStringMapBuilder> configurer,
@Nullable Boolean overwrite) {
Assert.notNull(configurer, "'configurer' must not be null");
StringStringMapBuilder builder = new StringStringMapBuilder();
configurer.accept(builder);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2020 the original author or authors.
* Copyright 2020-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* 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
}
fun defaultSubFlowMapping(subFlow: KotlinIntegrationFlowDefinition.() -> Unit) {
this.delegate.defaultSubFlowMapping { subFlow(KotlinIntegrationFlowDefinition(it)) }
defaultSubFlowMapping {definition -> subFlow(KotlinIntegrationFlowDefinition(definition)) }
}
fun defaultSubFlowMapping(subFlow: IntegrationFlow) {
this.delegate.defaultSubFlowMapping(subFlow)
}
fun defaultOutputToParentFlow() {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2020 the original author or authors.
* Copyright 2020-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -74,7 +74,11 @@ class KotlinEnricherSpec(val delegate: EnricherSpec)
}
fun requestSubFlow(subFlow: KotlinIntegrationFlowDefinition.() -> Unit) {
this.delegate.requestSubFlow { subFlow(KotlinIntegrationFlowDefinition(it)) }
requestSubFlow {definition -> subFlow(KotlinIntegrationFlowDefinition(definition)) }
}
fun requestSubFlow(subFlow: IntegrationFlow) {
this.delegate.requestSubFlow(subFlow)
}
fun shouldClonePayload(shouldClonePayload: Boolean) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2020 the original author or authors.
* Copyright 2020-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -48,7 +48,11 @@ class KotlinFilterEndpointSpec(val delegate: FilterEndpointSpec)
}
fun discardFlow(subFlow: KotlinIntegrationFlowDefinition.() -> Unit) {
this.delegate.discardFlow { subFlow(KotlinIntegrationFlowDefinition(it)) }
discardFlow {definition -> subFlow(KotlinIntegrationFlowDefinition(definition)) }
}
fun discardFlow(subFlow: IntegrationFlow) {
this.delegate.discardFlow(subFlow)
}
}

View File

@@ -836,7 +836,7 @@ class KotlinIntegrationFlowDefinition(@PublishedApi internal val delegate: Integ
routerConfigurer: KotlinRouterSpec<T, ExpressionEvaluatingRouter>.() -> Unit = {}
) {
this.delegate.route<T>(expression) { routerConfigurer(KotlinRouterSpec(it)) }
this.delegate.route(expression) { routerConfigurer(KotlinRouterSpec(it)) }
}
/**

View File

@@ -17,8 +17,6 @@
package org.springframework.integration.dsl
import org.springframework.expression.Expression
import org.springframework.integration.core.GenericSelector
import org.springframework.integration.core.MessageSelector
import org.springframework.integration.router.RecipientListRouter
import org.springframework.messaging.Message
import org.springframework.messaging.MessageChannel
@@ -77,15 +75,27 @@ class KotlinRecipientListRouterSpec(override val delegate: RecipientListRouterSp
}
fun recipientFlow(subFlow: KotlinIntegrationFlowDefinition.() -> Unit) {
this.delegate.recipientFlow { subFlow(KotlinIntegrationFlowDefinition(it)) }
recipientFlow { definition -> subFlow(KotlinIntegrationFlowDefinition(definition)) }
}
fun recipientFlow(expression: String, subFlow: KotlinIntegrationFlowDefinition.() -> Unit) {
this.delegate.recipientFlow(expression) { subFlow(KotlinIntegrationFlowDefinition(it)) }
recipientFlow(expression) { definition -> subFlow(KotlinIntegrationFlowDefinition(definition)) }
}
fun recipientFlow(expression: Expression, subFlow: KotlinIntegrationFlowDefinition.() -> Unit) {
this.delegate.recipientFlow(expression) { subFlow(KotlinIntegrationFlowDefinition(it)) }
recipientFlow(expression) { definition -> subFlow(KotlinIntegrationFlowDefinition(definition)) }
}
fun recipientFlow(subFlow: IntegrationFlow) {
this.delegate.recipientFlow(subFlow)
}
fun recipientFlow(expression: String, subFlow: IntegrationFlow) {
this.delegate.recipientFlow(expression, subFlow)
}
fun recipientFlow(expression: Expression, subFlow: IntegrationFlow) {
this.delegate.recipientFlow(expression, subFlow)
}
}

View File

@@ -60,7 +60,11 @@ class KotlinRouterSpec<K, R : AbstractMappingMessageRouter>(override val delegat
}
fun subFlowMapping(key: K, subFlow: KotlinIntegrationFlowDefinition.() -> Unit) {
this.delegate.subFlowMapping(key) { subFlow(KotlinIntegrationFlowDefinition(it)) }
subFlowMapping(key) { definition -> subFlow(KotlinIntegrationFlowDefinition(definition)) }
}
fun subFlowMapping(key: K, subFlow: IntegrationFlow) {
this.delegate.subFlowMapping(key, subFlow)
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2020 the original author or authors.
* Copyright 2020-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -48,7 +48,11 @@ class KotlinSplitterEndpointSpec<H : AbstractMessageSplitter>(val delegate: Spli
}
fun discardFlow(discardFlow: KotlinIntegrationFlowDefinition.() -> Unit) {
this.delegate.discardFlow { discardFlow(KotlinIntegrationFlowDefinition(it)) }
discardFlow {definition -> discardFlow(KotlinIntegrationFlowDefinition(definition)) }
}
fun discardFlow(discardFlow: IntegrationFlow) {
this.delegate.discardFlow(discardFlow)
}
}