From 22ef973541be0996ab7b8d09b3907f13e0075a02 Mon Sep 17 00:00:00 2001 From: Sven Diedrichsen Date: Mon, 4 Dec 2017 11:41:34 +0100 Subject: [PATCH] #478 remove obsolete NaturalNumbers and tests --- .../org/cactoos/iterable/NaturalNumbers.java | 100 ------------------ .../cactoos/iterable/NaturalNumbersTest.java | 80 -------------- .../java/org/cactoos/scalar/ReducedTest.java | 4 +- 3 files changed, 2 insertions(+), 182 deletions(-) delete mode 100644 src/main/java/org/cactoos/iterable/NaturalNumbers.java delete mode 100644 src/test/java/org/cactoos/iterable/NaturalNumbersTest.java diff --git a/src/main/java/org/cactoos/iterable/NaturalNumbers.java b/src/main/java/org/cactoos/iterable/NaturalNumbers.java deleted file mode 100644 index ac9d684678..0000000000 --- a/src/main/java/org/cactoos/iterable/NaturalNumbers.java +++ /dev/null @@ -1,100 +0,0 @@ -/** - * The MIT License (MIT) - * - * Copyright (c) 2017 Yegor Bugayenko - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -package org.cactoos.iterable; - -import java.util.stream.LongStream; -import org.cactoos.Scalar; -import org.cactoos.scalar.UncheckedScalar; - -/** - * Iterable providing Natural Numbers. - * - * @author Tim Hinkes (timmeey@timmeey.de) - * @version $Id$ - * @since 0.7 - */ -public final class NaturalNumbers extends IterableEnvelope { - - /** - * Ctor. - */ - public NaturalNumbers() { - this(Long.MAX_VALUE); - } - - /** - * Ctor. - * @param lst Last natural number - */ - public NaturalNumbers(final long lst) { - this(0L, lst); - } - - /** - * Ctor. - * @param fst First natural number - * @param lst Last natural number - */ - public NaturalNumbers(final long fst, final long lst) { - this(() -> fst, () -> lst); - } - - /** - * Ctor. - * @param lst Last natural number - */ - public NaturalNumbers(final Scalar lst) { - this(new UncheckedScalar<>(lst)); - } - - /** - * Ctor. - * @param lst Last natural number - */ - public NaturalNumbers(final UncheckedScalar lst) { - this(() -> 0L, lst); - } - - /** - * Ctor. - * @param fst First natural number - * @param lst Last natural number - */ - public NaturalNumbers(final Scalar fst, final Scalar lst) { - this(new UncheckedScalar<>(fst), new UncheckedScalar<>(lst)); - } - - /** - * Ctor. - * @param first First natural number - * @param last Last natural number - */ - public NaturalNumbers(final UncheckedScalar first, - final UncheckedScalar last) { - super(() -> () -> LongStream.range( - first.value(), last.value() - ).iterator()); - } - -} diff --git a/src/test/java/org/cactoos/iterable/NaturalNumbersTest.java b/src/test/java/org/cactoos/iterable/NaturalNumbersTest.java deleted file mode 100644 index 6b03e90fb3..0000000000 --- a/src/test/java/org/cactoos/iterable/NaturalNumbersTest.java +++ /dev/null @@ -1,80 +0,0 @@ -/** - * The MIT License (MIT) - * - * Copyright (c) 2017 Yegor Bugayenko - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -package org.cactoos.iterable; - -import org.cactoos.ScalarHasValue; -import org.hamcrest.MatcherAssert; -import org.hamcrest.Matchers; -import org.junit.Test; - -/** - * Test case for {@link NaturalNumbers}. - * - * @author Tim Hinkes (timmeey@timmeey.de) - * @version $Id$ - * @since 0.7 - * @checkstyle JavadocMethodCheck (500 lines) - */ -public final class NaturalNumbersTest { - - @Test - public void containsSequentialNaturalNumbers() { - MatcherAssert.assertThat( - "Can't get sequential natural numbers", - new NaturalNumbers(), - // @checkstyle MagicNumber (1 line) - Matchers.hasItems(0L, 1L, 5L, 10L) - ); - } - - @Test - public void notStartsWithNegativeNumbers() { - MatcherAssert.assertThat( - "Contains negative Numbers", - new ItemAt(0, new NaturalNumbers()), - new ScalarHasValue<>(0L) - ); - } - - @Test - public void containsNaturalNumbersRange() { - MatcherAssert.assertThat( - "Can't get range of natural numbers", - // @checkstyle MagicNumber (2 lines) - new NaturalNumbers(() -> 10L, () -> 15L), - Matchers.hasItems(10L, 12L, 14L) - ); - } - - @Test - public void containsNaturalNumbersRangeWithoutLast() { - MatcherAssert.assertThat( - "Can't get range of natural numbers without last", - // @checkstyle MagicNumber (2 lines) - new NaturalNumbers(() -> 5L), - Matchers.hasItems(0L, 1L, 2L, 3L, 4L) - ); - } - -} diff --git a/src/test/java/org/cactoos/scalar/ReducedTest.java b/src/test/java/org/cactoos/scalar/ReducedTest.java index 5888e5badf..7e5e7d9f6f 100644 --- a/src/test/java/org/cactoos/scalar/ReducedTest.java +++ b/src/test/java/org/cactoos/scalar/ReducedTest.java @@ -24,7 +24,7 @@ package org.cactoos.scalar; import org.cactoos.iterable.Limited; -import org.cactoos.iterable.NaturalNumbers; +import org.cactoos.iterable.RangeOf; import org.cactoos.iterable.Skipped; import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; @@ -46,7 +46,7 @@ public void skipIterable() throws Exception { "Can't reduce elements in iterable", new Reduced<>( 0L, (first, second) -> first + second, - new Limited<>(10, new NaturalNumbers()) + new Limited<>(10, new RangeOf.Long(0L, Long.MAX_VALUE)) ).value(), Matchers.equalTo(45L) );