Skip to content

Commit 4348c94

Browse files
authored
BEP refactor (helidon-io#2285)
* Alex's BEP refactor Signed-off-by: Daniel Kec <daniel.kec@oracle.com>
1 parent cda45a5 commit 4348c94

6 files changed

Lines changed: 338 additions & 222 deletions

File tree

common/reactive/src/main/java/io/helidon/common/reactive/BiConsumerChain.java

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020 Oracle and/or its affiliates.
2+
* Copyright (c) 2020, 2021 Oracle and/or its affiliates.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -30,13 +30,6 @@ public void accept(T t, S s) {
3030
}
3131
}
3232

33-
BiConsumerChain<T, S> combineWith(BiConsumer<? super T, ? super S> another) {
34-
BiConsumerChain<T, S> newChain = new BiConsumerChain<>();
35-
newChain.addAll(this);
36-
newChain.add(another);
37-
return newChain;
38-
}
39-
4033
static <T, S> BiConsumer<T, S> combine(
4134
BiConsumer<T, S> current,
4235
BiConsumer<T, S> another) {
@@ -46,12 +39,18 @@ static <T, S> BiConsumer<T, S> combine(
4639
if (another == null) {
4740
return current;
4841
}
42+
BiConsumerChain<T, S> newChain = new BiConsumerChain<>();
4943
if (current instanceof BiConsumerChain) {
50-
return ((BiConsumerChain<T, S>) current).combineWith(another);
44+
newChain.addAll((BiConsumerChain<T, S>) current);
45+
} else {
46+
newChain.add(current);
47+
}
48+
49+
if (another instanceof BiConsumerChain) {
50+
newChain.addAll((BiConsumerChain<T, S>) another);
51+
} else {
52+
newChain.add(another);
5153
}
52-
BiConsumerChain<T, S> newChain = new BiConsumerChain<>();
53-
newChain.add(current);
54-
newChain.add(another);
5554
return newChain;
5655
}
5756
}

0 commit comments

Comments
 (0)