Skip to content

Commit

Permalink
Revert BEP refactor (#3130)
Browse files Browse the repository at this point in the history
* Revert "BEP refactor (#2285)" - This reverts commit 4348c94.
* Test BEP in flatmap
* Revert copyright year

Signed-off-by: Daniel Kec <daniel.kec@oracle.com>
  • Loading branch information
danielkec authored Jun 20, 2021
1 parent e915fd8 commit 1c08b6a
Show file tree
Hide file tree
Showing 6 changed files with 243 additions and 334 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ public void accept(T t, S s) {
}
}

BiConsumerChain<T, S> combineWith(BiConsumer<? super T, ? super S> another) {
BiConsumerChain<T, S> newChain = new BiConsumerChain<>();
newChain.addAll(this);
newChain.add(another);
return newChain;
}

static <T, S> BiConsumer<T, S> combine(
BiConsumer<T, S> current,
BiConsumer<T, S> another) {
Expand All @@ -39,18 +46,12 @@ static <T, S> BiConsumer<T, S> combine(
if (another == null) {
return current;
}
BiConsumerChain<T, S> newChain = new BiConsumerChain<>();
if (current instanceof BiConsumerChain) {
newChain.addAll((BiConsumerChain<T, S>) current);
} else {
newChain.add(current);
}

if (another instanceof BiConsumerChain) {
newChain.addAll((BiConsumerChain<T, S>) another);
} else {
newChain.add(another);
return ((BiConsumerChain<T, S>) current).combineWith(another);
}
BiConsumerChain<T, S> newChain = new BiConsumerChain<>();
newChain.add(current);
newChain.add(another);
return newChain;
}
}
Loading

0 comments on commit 1c08b6a

Please sign in to comment.