diff --git a/src/main/java/org/cactoos/collection/HeadOf.java b/src/main/java/org/cactoos/collection/HeadOf.java deleted file mode 100644 index 24cf8bb22d..0000000000 --- a/src/main/java/org/cactoos/collection/HeadOf.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2017-2020 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.collection; - -import org.cactoos.iterable.IterableOf; - -/** - * Head portion of collection. - * - *

There is no thread-safety guarantee. - * - * @param Type of source item - * @since 0.29 - * @todo #1242:30min Remove this class and replace it everywhere - * it was needed by the appropriate usage of HeadOf from iterable - * (composed with ListOf or SetOf in case a copy is needed) - * or any other relevant concrete collection implementation. - * See #1242 for the rationale about this. - */ -public final class HeadOf extends CollectionEnvelope { - - /** - * Ctor. - * @param num Number of head elements - * @param src Source elements - */ - @SafeVarargs - public HeadOf(final int num, final T... src) { - this(num, new IterableOf<>(src)); - } - - /** - * Ctor. - * @param num Number of head elements - * @param src Source iterable - */ - public HeadOf(final int num, final Iterable src) { - super( - new Sticky<>( - new org.cactoos.iterable.HeadOf<>(num, src) - ) - ); - } - -} diff --git a/src/test/java/org/cactoos/collection/HeadOfTest.java b/src/test/java/org/cactoos/collection/HeadOfTest.java deleted file mode 100644 index f04bc76290..0000000000 --- a/src/test/java/org/cactoos/collection/HeadOfTest.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2017-2020 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.collection; - -import org.cactoos.iterable.IterableOf; -import org.hamcrest.core.AllOf; -import org.hamcrest.core.IsCollectionContaining; -import org.hamcrest.core.IsEqual; -import org.junit.Test; -import org.llorllale.cactoos.matchers.Assertion; - -/** - * Test Case for {@link HeadOf}. - * @since 0.29 - * @checkstyle JavadocMethodCheck (500 lines) - * @checkstyle MagicNumberCheck (500 lines) - */ -public final class HeadOfTest { - - @Test - @SuppressWarnings("PMD.AvoidDuplicateLiterals") - public void headCollection() { - new Assertion<>( - "Can't skip elements in iterable", - new HeadOf<>( - 3, - "one", "two", "three", "four" - ), - new AllOf<>( - new IterableOf>>( - new IsCollectionContaining<>(new IsEqual<>("one")), - new IsCollectionContaining<>(new IsEqual<>("two")), - new IsCollectionContaining<>(new IsEqual<>("three")) - ) - ) - ).affirm(); - } -}