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
This commit is contained in:
@@ -182,11 +182,10 @@ public class EnricherSpec extends ConsumerEndpointSpec<EnricherSpec, ContentEnri
|
||||
/**
|
||||
* @param key the key.
|
||||
* @param value the value.
|
||||
* @param <V> the value type.
|
||||
* @return the enricher spec.
|
||||
* @see ContentEnricher#setPropertyExpressions(Map)
|
||||
*/
|
||||
public <V> EnricherSpec property(String key, V value) {
|
||||
public EnricherSpec property(String key, Object value) {
|
||||
this.propertyExpressions.put(key, new ValueExpression<>(value));
|
||||
return _this();
|
||||
}
|
||||
@@ -220,11 +219,10 @@ public class EnricherSpec extends ConsumerEndpointSpec<EnricherSpec, ContentEnri
|
||||
* Set a header with the value if it is not already present.
|
||||
* @param name the header name.
|
||||
* @param value the value.
|
||||
* @param <V> the value type.
|
||||
* @return the enricher spec.
|
||||
* @see ContentEnricher#setHeaderExpressions(Map)
|
||||
*/
|
||||
public <V> EnricherSpec header(String name, V value) {
|
||||
public EnricherSpec header(String name, Object value) {
|
||||
return header(name, value, null);
|
||||
}
|
||||
|
||||
@@ -232,13 +230,12 @@ public class EnricherSpec extends ConsumerEndpointSpec<EnricherSpec, ContentEnri
|
||||
* @param name the header name.
|
||||
* @param value the value.
|
||||
* @param overwrite true to overwrite the header if already present.
|
||||
* @param <V> the value type.
|
||||
* @return the enricher spec.
|
||||
* @see ContentEnricher#setHeaderExpressions(Map)
|
||||
*/
|
||||
public <V> EnricherSpec header(String name, V value, @Nullable Boolean overwrite) {
|
||||
AbstractHeaderValueMessageProcessor<V> headerValueMessageProcessor =
|
||||
new StaticHeaderValueMessageProcessor<V>(value);
|
||||
public EnricherSpec header(String name, Object value, @Nullable Boolean overwrite) {
|
||||
AbstractHeaderValueMessageProcessor<Object> headerValueMessageProcessor =
|
||||
new StaticHeaderValueMessageProcessor<>(value);
|
||||
headerValueMessageProcessor.setOverwrite(overwrite);
|
||||
return header(name, headerValueMessageProcessor);
|
||||
}
|
||||
@@ -305,11 +302,10 @@ public class EnricherSpec extends ConsumerEndpointSpec<EnricherSpec, ContentEnri
|
||||
* Set a header value using an explicit {@link HeaderValueMessageProcessor}.
|
||||
* @param headerName the header name.
|
||||
* @param headerValueMessageProcessor the headerValueMessageProcessor.
|
||||
* @param <V> the value type.
|
||||
* @return the enricher spec.
|
||||
* @see ContentEnricher#setHeaderExpressions(Map)
|
||||
*/
|
||||
public <V> EnricherSpec header(String headerName, HeaderValueMessageProcessor<V> headerValueMessageProcessor) {
|
||||
public EnricherSpec header(String headerName, HeaderValueMessageProcessor<Object> headerValueMessageProcessor) {
|
||||
Assert.hasText(headerName, "'headerName' must not be empty");
|
||||
this.headerExpressions.put(headerName, headerValueMessageProcessor);
|
||||
return _this();
|
||||
|
||||
@@ -85,7 +85,7 @@ class KotlinEnricherSpec(override val delegate: EnricherSpec)
|
||||
this.delegate.shouldClonePayload(shouldClonePayload)
|
||||
}
|
||||
|
||||
fun <V> property(key: String, value: V) {
|
||||
fun property(key: String, value: Any) {
|
||||
this.delegate.property(key, value)
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ class KotlinEnricherSpec(override val delegate: EnricherSpec)
|
||||
this.delegate.propertyFunction(key, function)
|
||||
}
|
||||
|
||||
fun <V> header(name: String, value: V, overwrite: Boolean?) {
|
||||
fun header(name: String, value: Any, overwrite: Boolean?) {
|
||||
this.delegate.header(name, value, overwrite)
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ class KotlinEnricherSpec(override val delegate: EnricherSpec)
|
||||
this.delegate.header(name, function, overwrite)
|
||||
}
|
||||
|
||||
fun <V> header(headerName: String, headerValueMessageProcessor: HeaderValueMessageProcessor<V>) {
|
||||
fun header(headerName: String, headerValueMessageProcessor: HeaderValueMessageProcessor<Any>) {
|
||||
this.delegate.header(headerName, headerValueMessageProcessor)
|
||||
}
|
||||
|
||||
|
||||
@@ -1043,7 +1043,7 @@ class KotlinIntegrationFlowDefinition(@PublishedApi internal val delegate: Integ
|
||||
* current integration flow position.
|
||||
* In addition, accept options for the integration endpoint using [GenericEndpointSpec].
|
||||
*/
|
||||
fun <R : AbstractMessageRouter?> route(router: R, endpointConfigurer: GenericEndpointSpec<R>.() -> Unit = {}) {
|
||||
fun <R : AbstractMessageRouter> route(router: R, endpointConfigurer: GenericEndpointSpec<R>.() -> Unit = {}) {
|
||||
this.delegate.route(router, endpointConfigurer)
|
||||
}
|
||||
|
||||
|
||||
@@ -51,19 +51,19 @@ class KotlinRouterSpec<K, R : AbstractMappingMessageRouter>(override val delegat
|
||||
this.delegate.channelKeyFallback(channelKeyFallback)
|
||||
}
|
||||
|
||||
fun channelMapping(key: K, channelName: String) {
|
||||
fun channelMapping(key: K & Any, channelName: String) {
|
||||
this.delegate.channelMapping(key, channelName)
|
||||
}
|
||||
|
||||
fun channelMapping(key: K, channel: MessageChannel) {
|
||||
fun channelMapping(key: K & Any, channel: MessageChannel) {
|
||||
this.delegate.channelMapping(key, channel)
|
||||
}
|
||||
|
||||
fun subFlowMapping(key: K, subFlow: KotlinIntegrationFlowDefinition.() -> Unit) {
|
||||
fun subFlowMapping(key: K & Any, subFlow: KotlinIntegrationFlowDefinition.() -> Unit) {
|
||||
subFlowMapping(key) { definition -> subFlow(KotlinIntegrationFlowDefinition(definition)) }
|
||||
}
|
||||
|
||||
fun subFlowMapping(key: K, subFlow: IntegrationFlow) {
|
||||
fun subFlowMapping(key: K & Any, subFlow: IntegrationFlow) {
|
||||
this.delegate.subFlowMapping(key, subFlow)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user