Skip to content

Commit

Permalink
Merge branch '__rultor'
Browse files Browse the repository at this point in the history
  • Loading branch information
rultor committed May 13, 2021
2 parents 91d8840 + 37dec6f commit 9fbb757
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
12 changes: 6 additions & 6 deletions src/main/java/org/cactoos/func/FuncWithFallback.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,20 +95,21 @@ public final class FuncWithFallback<X, Y> implements Func<X, Y> {
/**
* The func.
*/
private final Func<X, Y> func;
private final Func<? super X, ? extends Y> func;

/**
* The fallbacks.
*/
private final Iterable<Fallback<Y>> fallbacks;
private final Iterable<? extends Fallback<? extends Y>> fallbacks;

/**
* Ctor.
* @param fnc The func
* @param fbks The fallbacks
*/
@SafeVarargs
public FuncWithFallback(final Func<X, Y> fnc, final Fallback<Y>... fbks) {
public FuncWithFallback(final Func<? super X, ? extends Y> fnc,
final Fallback<? extends Y>... fbks) {
this(fnc, new IterableOf<>(fbks));
}

Expand All @@ -117,9 +118,8 @@ public FuncWithFallback(final Func<X, Y> fnc, final Fallback<Y>... fbks) {
* @param fnc The func
* @param fbks The fallbacks
*/
public FuncWithFallback(
final Func<X, Y> fnc, final Iterable<Fallback<Y>> fbks
) {
public FuncWithFallback(final Func<? super X, ? extends Y> fnc,
final Iterable<? extends Fallback<? extends Y>> fbks) {
this.func = fnc;
this.fallbacks = fbks;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/cactoos/func/package-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
* Functions.
*
* @since 0.1
* @todo #1533:30min Exploit generic variance for package org.cactoos.func
* @todo #1572:30min Exploit generic variance for package org.cactoos.func
* to ensure typing works as best as possible as it is explained in
* #1533 issue.
*/
Expand Down
16 changes: 8 additions & 8 deletions src/main/java/org/cactoos/scalar/ScalarWithFallback.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ public final class ScalarWithFallback<T> implements Scalar<T> {
/**
* The origin scalar.
*/
private final Scalar<T> origin;
private final Scalar<? extends T> origin;

/**
* The fallback.
*/
private final Iterable<Fallback<T>> fallbacks;
private final Iterable<? extends Fallback<? extends T>> fallbacks;

/**
* Ctor.
Expand All @@ -63,8 +63,8 @@ public final class ScalarWithFallback<T> implements Scalar<T> {
*/
@SafeVarargs
public ScalarWithFallback(
final Scalar<T> origin,
final Fallback<T>... fbks
final Scalar<? extends T> origin,
final Fallback<? extends T>... fbks
) {
this(origin, new IterableOf<>(fbks));
}
Expand All @@ -74,8 +74,8 @@ public ScalarWithFallback(
* @param origin Original scalar
* @param fbks Fallbacks
*/
public ScalarWithFallback(final Scalar<T> origin,
final Iterable<Fallback<T>> fbks) {
public ScalarWithFallback(final Scalar<? extends T> origin,
final Iterable<? extends Fallback<? extends T>> fbks) {
this.origin = origin;
this.fallbacks = fbks;
}
Expand Down Expand Up @@ -105,7 +105,7 @@ public T value() throws Exception {
*/
@SuppressWarnings("PMD.AvoidThrowingRawExceptionTypes")
private T fallback(final Throwable exp) throws Exception {
final Iterator<Map.Entry<Fallback<T>, Integer>> candidates =
final Iterator<? extends Map.Entry<Fallback<? extends T>, Integer>> candidates =
new Sorted<>(
Comparator.comparing(Map.Entry::getValue),
new Filtered<>(
Expand All @@ -117,7 +117,7 @@ private T fallback(final Throwable exp) throws Exception {
)
)
),
new MapOf<>(
new MapOf<Fallback<? extends T>, Integer>(
fbk -> fbk,
fbk -> fbk.support(exp),
this.fallbacks
Expand Down

2 comments on commit 9fbb757

@0pdd
Copy link
Collaborator

@0pdd 0pdd commented on 9fbb757 May 13, 2021

Choose a reason for hiding this comment

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

Puzzle 1533-37aa2e90 disappeared from src/main/java/org/cactoos/func/package-info.java, that's why I closed #1572. Please, remember that the puzzle was not necessarily removed in this particular commit. Maybe it happened earlier, but we discovered this fact only now.

@0pdd
Copy link
Collaborator

@0pdd 0pdd commented on 9fbb757 May 13, 2021

Choose a reason for hiding this comment

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

Puzzle 1572-37aa2e90 discovered in src/main/java/org/cactoos/func/package-info.java and submitted as #1613. 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.