Skip to content

Commit

Permalink
refactor: delegate Cffu.peek() methods to `CompletableFutureUtils.p…
Browse files Browse the repository at this point in the history
…eek()` which has report function 🫣
  • Loading branch information
oldratlee committed Jun 6, 2024
1 parent ed817b9 commit b674fd9
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions cffu-core/src/main/java/io/foldright/cffu/Cffu.java
Original file line number Diff line number Diff line change
Expand Up @@ -1198,7 +1198,7 @@ public Cffu<T> exceptionallyComposeAsync(
* @param <U> the function's return type
* @return the new Cffu
*/
@CheckReturnValue(explanation = "should use the returned Cffu; otherwise, prefer method `whenComplete`")
@CheckReturnValue(explanation = "should use the returned Cffu; otherwise, prefer method `peek`")
@Override
public <U> Cffu<U> handle(BiFunction<? super T, Throwable, ? extends U> fn) {
return reset0(cf.handle(fn));
Expand All @@ -1217,7 +1217,7 @@ public <U> Cffu<U> handle(BiFunction<? super T, Throwable, ? extends U> fn) {
* @param <U> the function's return type
* @return the new Cffu
*/
@CheckReturnValue(explanation = "should use the returned Cffu; otherwise, prefer method `whenCompleteAsync`")
@CheckReturnValue(explanation = "should use the returned Cffu; otherwise, prefer method `peekAsync`")
@Override
public <U> Cffu<U> handleAsync(BiFunction<? super T, Throwable, ? extends U> fn) {
return handleAsync(fn, fac.defaultExecutor());
Expand All @@ -1237,7 +1237,7 @@ public <U> Cffu<U> handleAsync(BiFunction<? super T, Throwable, ? extends U> fn)
* @param <U> the function's return type
* @return the new Cffu
*/
@CheckReturnValue(explanation = "should use the returned Cffu; otherwise, prefer method `whenCompleteAsync`")
@CheckReturnValue(explanation = "should use the returned Cffu; otherwise, prefer method `peekAsync`")
@Override
public <U> Cffu<U> handleAsync(
BiFunction<? super T, Throwable, ? extends U> fn, Executor executor) {
Expand All @@ -1263,6 +1263,7 @@ public <U> Cffu<U> handleAsync(
* @return the new Cffu
*/
@Override
@CheckReturnValue(explanation = "should use the returned Cffu; otherwise, prefer method `peek`")
public Cffu<T> whenComplete(BiConsumer<? super T, ? super Throwable> action) {
return reset0(cf.whenComplete(action));
}
Expand All @@ -1288,6 +1289,7 @@ public Cffu<T> whenComplete(BiConsumer<? super T, ? super Throwable> action) {
* @return the new Cffu
*/
@Override
@CheckReturnValue(explanation = "should use the returned Cffu; otherwise, prefer method `peekAsync`")
public Cffu<T> whenCompleteAsync(BiConsumer<? super T, ? super Throwable> action) {
return whenCompleteAsync(action, fac.defaultExecutor());
}
Expand All @@ -1313,6 +1315,7 @@ public Cffu<T> whenCompleteAsync(BiConsumer<? super T, ? super Throwable> action
* @return the new Cffu
*/
@Override
@CheckReturnValue(explanation = "should use the returned Cffu; otherwise, prefer method `peekAsync`")
public Cffu<T> whenCompleteAsync(BiConsumer<? super T, ? super Throwable> action, Executor executor) {
return reset0(cf.whenCompleteAsync(action, executor));
}
Expand All @@ -1334,7 +1337,7 @@ public Cffu<T> whenCompleteAsync(BiConsumer<? super T, ? super Throwable> action
* @see java.util.stream.Stream#peek(Consumer)
*/
public Cffu<T> peek(BiConsumer<? super T, ? super Throwable> action) {
cf.whenComplete(action);
CompletableFutureUtils.peek(cf, action);
return this;
}

Expand Down Expand Up @@ -1377,7 +1380,7 @@ public Cffu<T> peekAsync(BiConsumer<? super T, ? super Throwable> action) {
* @see java.util.stream.Stream#peek(Consumer)
*/
public Cffu<T> peekAsync(BiConsumer<? super T, ? super Throwable> action, Executor executor) {
cf.whenCompleteAsync(action, executor);
CompletableFutureUtils.peekAsync(cf, action, executor);
return this;
}

Expand Down

0 comments on commit b674fd9

Please sign in to comment.