Skip to content

Commit 9eac42c

Browse files
committed
rename ifPresentOrElse to ifLeftOrElse
1 parent caec987 commit 9eac42c

File tree

6 files changed

+13
-12
lines changed

6 files changed

+13
-12
lines changed

src/main/java/io/jbock/util/Either.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ public abstract <U> U fold(
187187
* @param leftAction action to run if this is a Left
188188
* @param rightAction action to run if this is a Right
189189
*/
190-
public abstract void ifPresentOrElse(
190+
public abstract void ifLeftOrElse(
191191
Consumer<? super L> leftAction,
192192
Consumer<? super R> rightAction);
193193

@@ -208,16 +208,16 @@ public final boolean isRight() {
208208
}
209209

210210
/**
211-
* If this is a Left, return a {@code LeftOptional} containing the LHS value.
212-
* Otherwise return an empty {@code LeftOptional}.
211+
* If this is a Left, returns a {@code LeftOptional} containing the LHS value.
212+
* Otherwise returns an empty {@code LeftOptional}.
213213
*
214214
* @return the LHS value, or {@link java.util.Optional#empty()} if this is a Right
215215
*/
216216
public abstract LeftOptional<L> getLeft();
217217

218218
/**
219-
* If this is a Right, return an {@code Optional} containing the RHS value.
220-
* Otherwise return an empty {@code Optional}.
219+
* If this is a Right, returns an {@code Optional} containing the RHS value.
220+
* Otherwise returns an empty {@code Optional}.
221221
*
222222
* @return the RHS value if this is a Right, otherwise an empty {@code Optional}
223223
*/

src/main/java/io/jbock/util/Left.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public <U> U fold(
7979
}
8080

8181
@Override
82-
public void ifPresentOrElse(Consumer<? super L> leftAction, Consumer<? super R> rightAction) {
82+
public void ifLeftOrElse(Consumer<? super L> leftAction, Consumer<? super R> rightAction) {
8383
leftAction.accept(value);
8484
}
8585

src/main/java/io/jbock/util/Right.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public <U> U fold(
7979
}
8080

8181
@Override
82-
public void ifPresentOrElse(Consumer<? super L> leftAction, Consumer<? super R> rightAction) {
82+
public void ifLeftOrElse(Consumer<? super L> leftAction, Consumer<? super R> rightAction) {
8383
rightAction.accept(value);
8484
}
8585

src/main/java/io/jbock/util/ValidatingCollector.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ void accumulate(Either<L, R> either) {
2626
if (left != null) {
2727
return;
2828
}
29-
either.ifPresentOrElse(l -> left = l,
29+
either.ifLeftOrElse(
30+
left -> this.left = left,
3031
right::add);
3132
}
3233

src/main/java/io/jbock/util/ValidatingCollectorAll.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ static final class Acc<L, R> {
2424

2525
void accumulate(Either<L, R> either) {
2626
if (!left.isEmpty()) {
27-
either.ifPresentOrElse(left::add, r -> {
27+
either.ifLeftOrElse(left::add, r -> {
2828
});
2929
} else {
30-
either.ifPresentOrElse(left::add, right::add);
30+
either.ifLeftOrElse(left::add, right::add);
3131
}
3232
}
3333

src/test/java/io/jbock/util/EitherTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,10 @@ void testOrElseThrow() {
120120
void testAccept() {
121121
String[] output = {"1"};
122122
Either<Integer, Integer> left = Either.left(1);
123-
left.ifPresentOrElse(l -> output[0] = "L", r -> output[0] = "R");
123+
left.ifLeftOrElse(l -> output[0] = "L", r -> output[0] = "R");
124124
assertEquals("L", output[0]);
125125
Either<Integer, Integer> right = Either.right(1);
126-
right.ifPresentOrElse(l -> output[0] = "L", r -> output[0] = "R");
126+
right.ifLeftOrElse(l -> output[0] = "L", r -> output[0] = "R");
127127
assertEquals("R", output[0]);
128128
}
129129

0 commit comments

Comments
 (0)