Skip to content

Commit

Permalink
Fix new Sonar smells
Browse files Browse the repository at this point in the history
* And more convenient Kotlin methods based on `IntegrationFlow`
  • Loading branch information
artembilan committed Apr 16, 2023
1 parent 869c5c7 commit fa178c3
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,9 @@ public HeaderEnricherSpec headerExpressions(Consumer<StringStringMapBuilder> con
* @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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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)) }
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

}
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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)
}

}

0 comments on commit fa178c3

Please sign in to comment.