From 814caea5d536c76c5af743bfddb811848add7b47 Mon Sep 17 00:00:00 2001 From: Artem Bilan Date: Mon, 10 Feb 2014 19:10:02 +0200 Subject: [PATCH] INT-3293: Add Lambda Strategies JIRA: https://jira.springsource.org/browse/INT-3293 --- .../integration/core/GenericSelector.java | 31 ++++++++++++++++++ .../integration/core/MessageSelector.java | 4 +-- .../transformer/GenericTransformer.java | 32 +++++++++++++++++++ .../integration/transformer/Transformer.java | 4 +-- 4 files changed, 67 insertions(+), 4 deletions(-) create mode 100644 spring-integration-core/src/main/java/org/springframework/integration/core/GenericSelector.java create mode 100644 spring-integration-core/src/main/java/org/springframework/integration/transformer/GenericTransformer.java diff --git a/spring-integration-core/src/main/java/org/springframework/integration/core/GenericSelector.java b/spring-integration-core/src/main/java/org/springframework/integration/core/GenericSelector.java new file mode 100644 index 0000000000..1db7ecfc9e --- /dev/null +++ b/spring-integration-core/src/main/java/org/springframework/integration/core/GenericSelector.java @@ -0,0 +1,31 @@ +/* + * Copyright 2002-2010 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.integration.core; + +/** + * Generic (lambda) strategy interface for selector. + * + * @param the source type to accept. + * + * @author Artem Bilan + * @since 4.0 + */ +public interface GenericSelector { + + boolean accept(S source); + +} diff --git a/spring-integration-core/src/main/java/org/springframework/integration/core/MessageSelector.java b/spring-integration-core/src/main/java/org/springframework/integration/core/MessageSelector.java index bdd25735b6..292873f795 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/core/MessageSelector.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/core/MessageSelector.java @@ -20,10 +20,10 @@ import org.springframework.messaging.Message; /** * Strategy interface for message selection. - * + * * @author Mark Fisher */ -public interface MessageSelector { +public interface MessageSelector extends GenericSelector> { boolean accept(Message message); diff --git a/spring-integration-core/src/main/java/org/springframework/integration/transformer/GenericTransformer.java b/spring-integration-core/src/main/java/org/springframework/integration/transformer/GenericTransformer.java new file mode 100644 index 0000000000..e575a4f11d --- /dev/null +++ b/spring-integration-core/src/main/java/org/springframework/integration/transformer/GenericTransformer.java @@ -0,0 +1,32 @@ +/* + * Copyright 2014 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.integration.transformer; + +/** + * Generic (lambda) strategy interface for transformer. + * + * @param the source type - 'transform from'. + * @param the target type - 'transform to'. + * + * @author Artem Bilan + * @since 4.0 + */ +public interface GenericTransformer { + + T transform(S source); + +} diff --git a/spring-integration-core/src/main/java/org/springframework/integration/transformer/Transformer.java b/spring-integration-core/src/main/java/org/springframework/integration/transformer/Transformer.java index 130cc92267..2b3d7af709 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/transformer/Transformer.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/transformer/Transformer.java @@ -20,10 +20,10 @@ import org.springframework.messaging.Message; /** * Strategy interface for transforming a {@link Message}. - * + * * @author Mark Fisher */ -public interface Transformer { +public interface Transformer extends GenericTransformer, Message> { Message transform(Message message);