Skip to content

Commit

Permalink
Resolve conflicts with master #1449
Browse files Browse the repository at this point in the history
  • Loading branch information
Olivier B. OURA committed Mar 14, 2021
2 parents 457e647 + 297f626 commit 047fb51
Show file tree
Hide file tree
Showing 49 changed files with 1,787 additions and 718 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ jobs:
- name: Test
run: mvn clean test --errors --batch-mode
- name: CodeCov
uses: codecov/[email protected]
if: matrix.os == 'ubuntu-18.04' && github.repository == 'yegor256/cactoos'
timeout-minutes: 10
uses: codecov/codecov-action@v1
if: matrix.os == 'ubuntu-18.04' && matrix.java == 8 && github.repository == 'yegor256/cactoos'
with:
file: target/coverage/jacoco.xml

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/cactoos/bytes/CheckedBytes.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ public final class CheckedBytes<E extends Exception> implements Bytes {
/**
* Function that wraps exception of {@link #origin} to the required type.
*/
private final Func<Exception, E> func;
private final Func<? super Exception, ? extends E> func;

/**
* Ctor.
* @param orig Origin bytes.
* @param fnc Function that wraps exceptions.
*/
public CheckedBytes(final Bytes orig, final Func<Exception, E> fnc) {
public CheckedBytes(final Bytes orig, final Func<? super Exception, ? extends E> fnc) {
this.origin = orig;
this.func = fnc;
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/cactoos/bytes/UncheckedBytes.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public final class UncheckedBytes implements Bytes {
/**
* Fallback.
*/
private final Func<Exception, byte[]> fallback;
private final Func<? super Exception, byte[]> fallback;

/**
* Ctor.
Expand All @@ -67,7 +67,7 @@ public UncheckedBytes(final Bytes bts) {
* @since 0.5
*/
public UncheckedBytes(final Bytes bts,
final Func<Exception, byte[]> fbk) {
final Func<? super Exception, byte[]> fbk) {
this.bytes = bts;
this.fallback = fbk;
}
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/org/cactoos/collection/package-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,8 @@
* Collections, tests.
*
* @since 0.14
* @todo #1533:30min Continue to exploit generic variance for package
* org.cactoos.collection to ensure typing works as best as
* possible as it is explained in #1533 issue.
*/
package org.cactoos.collection;
2 changes: 2 additions & 0 deletions src/main/java/org/cactoos/experimental/package-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,7 @@
* whatsoever.
*
* @since 1.0.0
* @todo #1533:30min Exploit generic variance for package org.cactoos.experimental
* to ensure typing works as best as possible as it is explained in #1533 issue.
*/
package org.cactoos.experimental;
3 changes: 3 additions & 0 deletions src/main/java/org/cactoos/func/package-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,8 @@
* Functions.
*
* @since 0.1
* @todo #1533:30min Exploit generic variance for package org.cactoos.func
* to ensure typing works as best as possible as it is explained in
* #1533 issue.
*/
package org.cactoos.func;
3 changes: 3 additions & 0 deletions src/main/java/org/cactoos/io/package-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,8 @@
* to them and document them about this behaviour and refer them to the existence
* of {@link org.cactoos.io.CloseShieldInput} and {@link org.cactoos.io.CloseShieldOutput}
* and how to use them.
* @todo #1533:30min Exploit generic variance for package org.cactoos.io
* to ensure typing works as best as possible as it is explained in
* #1533 issue.
*/
package org.cactoos.io;
67 changes: 67 additions & 0 deletions src/main/java/org/cactoos/iterable/MappedWithIndex.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
* 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.iterable;

import org.cactoos.BiFunc;

/**
* Mapped with index iterable.
*
* <p>
* There is no thread-safety guarantee.
* @param <Y> Type of target item
* @since 1.0.0
*/
public final class MappedWithIndex<Y> extends IterableEnvelope<Y> {
/**
* Ctor.
* @param fnc Func
* @param src Source iterable
* @param <X> Type of source item
*/
@SafeVarargs
public <X> MappedWithIndex(
final BiFunc<? super X, Integer, ? extends Y> fnc,
final X... src
) {
this(fnc, new IterableOf<>(src));
}

/**
* Ctor.
* @param fnc Func
* @param src Source iterable
* @param <X> Type of source item
*/
public <X> MappedWithIndex(
final BiFunc<? super X, Integer, ? extends Y> fnc,
final Iterable<? extends X> src
) {
super(
new IterableOf<>(
() -> new org.cactoos.iterator.MappedWithIndex<>(fnc, src.iterator())
)
);
}
}
3 changes: 3 additions & 0 deletions src/main/java/org/cactoos/iterable/package-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,8 @@
* Iterables.
*
* @since 0.12
* @todo #1533:30min Exploit generic variance for package org.cactoos.iterable
* to ensure typing works as best as possible as it is explained in
* #1533 issue.
*/
package org.cactoos.iterable;
75 changes: 75 additions & 0 deletions src/main/java/org/cactoos/iterator/MappedWithIndex.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/*
* 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.iterator;

import java.util.Iterator;
import java.util.concurrent.atomic.AtomicInteger;
import org.cactoos.BiFunc;

/**
* Mapped with index iterator.
*
* <p>
* There is no thread-safety guarantee.
* @param <Y> Type of target item
* @since 1.0.0
*/
public final class MappedWithIndex<Y> extends IteratorEnvelope<Y> {
/**
* Ctor.
* @param func Func
* @param iterator Source iterator
* @param <X> Type of item
*/
public <X> MappedWithIndex(
final BiFunc<? super X, Integer, ? extends Y> func,
final Iterator<? extends X> iterator
) {
this(
new AtomicInteger(-1),
func,
iterator
);
}

/**
* Privated Ctor.
* @param indexcounter Index Counter
* @param func Func
* @param iterator Source iterator
* @param <X> Type of item
*/
private <X> MappedWithIndex(
final AtomicInteger indexcounter,
final BiFunc<? super X, Integer, ? extends Y> func,
final Iterator<? extends X> iterator
) {
super(
new Mapped<>(
item -> func.apply(item, indexcounter.incrementAndGet()),
iterator
)
);
}
}
3 changes: 3 additions & 0 deletions src/main/java/org/cactoos/iterator/package-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,8 @@
* Iterators.
*
* @since 0.12
* @todo #1533:30min Exploit generic variance for package org.cactoos.iterator
* to ensure typing works as best as possible as it is explained in
* #1533 issue.
*/
package org.cactoos.iterator;
3 changes: 3 additions & 0 deletions src/main/java/org/cactoos/list/Joined.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
*
* @param <X> Type of source item
* @since 0.20
* @todo #1254:30min Make {@link Joined} implements directly {@link List}
* and delegate each operation to {@link JoinedListIterator} as if lists
* joined were one list.
*/
public final class Joined<X> extends ListEnvelope<X> {

Expand Down
Loading

1 comment on commit 047fb51

@0pdd
Copy link
Collaborator

@0pdd 0pdd commented on 047fb51 Mar 22, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Puzzle 1449-0c19404b discovered in src/main/java/org/cactoos/io/package-info.java and submitted as #1577. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.

Please sign in to comment.