Skip to content

Commit be116bb

Browse files
committed
remove orElseThrow
1 parent e98b394 commit be116bb

File tree

4 files changed

+0
-33
lines changed

4 files changed

+0
-33
lines changed

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

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -155,18 +155,6 @@ public abstract <L2> Either<L2, R> flatMapLeft(
155155
public abstract Either<L, R> filterLeft(
156156
Function<? super L, Optional<? extends R>> predicate);
157157

158-
/**
159-
* If this is a Right, returns the RHS value.
160-
* Otherwise throws an exception produced by the exception supplying function.
161-
*
162-
* @param exceptionSupplier exception supplying function
163-
* @param <X> type of the exception
164-
* @return the RHS value, if this is a Right
165-
* @throws X the result of applying {@code exceptionSupplier} to the LHS value, if this is a Left
166-
*/
167-
public abstract <X extends Throwable> R orElseThrow(
168-
Function<? super L, ? extends X> exceptionSupplier) throws X;
169-
170158
/**
171159
* If this is a Left, returns the result of applying the {@code leftMapper} to the LHS value.
172160
* Otherwise returns the result of applying the {@code rightMapper} to the RHS value.

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,6 @@ public Either<L, R> filterLeft(Function<? super L, Optional<? extends R>> predic
6666
return Right.create(test.orElseThrow());
6767
}
6868

69-
@Override
70-
public <X extends Throwable> R orElseThrow(Function<? super L, ? extends X> exceptionSupplier) throws X {
71-
throw exceptionSupplier.apply(value);
72-
}
73-
7469
@Override
7570
public <U> U fold(
7671
Function<? super L, ? extends U> leftMapper,

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,6 @@ public Either<L, R> filterLeft(Function<? super L, Optional<? extends R>> predic
6666
return same();
6767
}
6868

69-
@Override
70-
public <X extends Throwable> R orElseThrow(Function<? super L, ? extends X> exceptionSupplier) throws X {
71-
return value;
72-
}
73-
7469
@Override
7570
public <U> U fold(
7671
Function<? super L, ? extends U> leftMapper,

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

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,12 @@
33
import com.google.common.testing.EqualsTester;
44
import org.junit.jupiter.api.Test;
55

6-
import java.io.IOException;
76
import java.util.Objects;
87
import java.util.Optional;
98

109
import static org.junit.jupiter.api.Assertions.assertEquals;
1110
import static org.junit.jupiter.api.Assertions.assertFalse;
1211
import static org.junit.jupiter.api.Assertions.assertSame;
13-
import static org.junit.jupiter.api.Assertions.assertThrows;
1412
import static org.junit.jupiter.api.Assertions.assertTrue;
1513

1614
class EitherTest {
@@ -107,15 +105,6 @@ void testFilterLeft() {
107105
assertEquals(left, left.filterLeft(r -> Optional.empty()));
108106
}
109107

110-
@Test
111-
void testOrElseThrow() {
112-
Either<String, ?> left = Either.left("1");
113-
IOException x = assertThrows(IOException.class, () -> left.orElseThrow(IOException::new));
114-
assertEquals("1", x.getMessage());
115-
Either<String, String> right = Either.right("2");
116-
assertEquals("2", right.orElseThrow(IllegalArgumentException::new));
117-
}
118-
119108
@Test
120109
void testAccept() {
121110
String[] output = {"1"};

0 commit comments

Comments
 (0)