JAMES-1781 FunctionGenerator interface is no more needed
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/7d352250 Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/7d352250 Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/7d352250 Branch: refs/heads/master Commit: 7d352250bea07f83e41edb2e9e4ef40d09d7af4d Parents: 1ebb82c Author: Benoit Tellier <[email protected]> Authored: Wed Sep 28 11:33:35 2016 +0200 Committer: Benoit Tellier <[email protected]> Committed: Thu Sep 29 12:51:01 2016 +0200 ---------------------------------------------------------------------- .../apache/james/util/FunctionGenerator.java | 29 ---------- .../james/util/FunctionGeneratorTest.java | 58 -------------------- 2 files changed, 87 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/james-project/blob/7d352250/server/container/util-java8/src/main/java/org/apache/james/util/FunctionGenerator.java ---------------------------------------------------------------------- diff --git a/server/container/util-java8/src/main/java/org/apache/james/util/FunctionGenerator.java b/server/container/util-java8/src/main/java/org/apache/james/util/FunctionGenerator.java deleted file mode 100644 index 2342360..0000000 --- a/server/container/util-java8/src/main/java/org/apache/james/util/FunctionGenerator.java +++ /dev/null @@ -1,29 +0,0 @@ -/**************************************************************** - * Licensed to the Apache Software Foundation (ASF) under one * - * or more contributor license agreements. See the NOTICE file * - * distributed with this work for additional information * - * regarding copyright ownership. The ASF licenses this file * - * to you 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.apache.james.util; - -import java.util.function.Function; - -@FunctionalInterface -public interface FunctionGenerator<A, R> extends Function<A, Function<R, R>> { - default FunctionGenerator<A, R> composeGeneratedFunctions(FunctionGenerator<A, R> other) { - return a -> apply(a).compose(other.apply(a)); - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/james-project/blob/7d352250/server/container/util-java8/src/test/java/org/apache/james/util/FunctionGeneratorTest.java ---------------------------------------------------------------------- diff --git a/server/container/util-java8/src/test/java/org/apache/james/util/FunctionGeneratorTest.java b/server/container/util-java8/src/test/java/org/apache/james/util/FunctionGeneratorTest.java deleted file mode 100644 index 9a7da21..0000000 --- a/server/container/util-java8/src/test/java/org/apache/james/util/FunctionGeneratorTest.java +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************** - * Licensed to the Apache Software Foundation (ASF) under one * - * or more contributor license agreements. See the NOTICE file * - * distributed with this work for additional information * - * regarding copyright ownership. The ASF licenses this file * - * to you 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.apache.james.util; - -import static org.assertj.core.api.Assertions.assertThat; - -import java.util.function.Function; - -import org.junit.Test; - -public class FunctionGeneratorTest { - - @Test - public void composeGeneratedFunctionsShouldProduceTheCompositionOfBothOperations() { - FunctionGenerator<Integer, Integer> generateAddition = i -> (j -> j + i); - - Function<Integer, Integer> addSix = generateAddition.composeGeneratedFunctions(generateAddition).apply(3); - - assertThat(addSix.apply(42)).isEqualTo(48); - } - - @Test - public void composeGeneratedFunctionsShouldProduceTheCompositionOfBothOperationsWithDifferentArguments() { - FunctionGenerator<Integer, Integer> generateAddition = i -> (j -> j + i); - FunctionGenerator<Integer, Integer> generateDoubleAddition = i -> (j -> j + 2 * i); - - Function<Integer, Integer> addNine = generateAddition.composeGeneratedFunctions(generateDoubleAddition).apply(3); - - assertThat(addNine.apply(42)).isEqualTo(51); - } - - @Test - public void composeGeneratedFunctionsShouldReturnSameResultWhenOperationsCommute() { - FunctionGenerator<Integer, Integer> generateAddition = i -> (j -> j + i); - FunctionGenerator<Integer, Integer> generateDoubleAddition = i -> (j -> j + 2 * i); - - Function<Integer, Integer> addNine = generateDoubleAddition.composeGeneratedFunctions(generateAddition).apply(3); - - assertThat(addNine.apply(42)).isEqualTo(51); - } -} --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
