Remove CheckedValue.orElseThrow(Supplier) 14/101114/1
authorRobert Varga <robert.varga@pantheon.tech>
Fri, 13 May 2022 13:00:30 +0000 (15:00 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Fri, 13 May 2022 13:03:48 +0000 (15:03 +0200)
This method has been deprecated, remove it.

Change-Id: Iacb84d93ffedcd000157a35807a9a9951553bbf1
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
common/concepts/src/main/java/org/opendaylight/yangtools/concepts/CheckedValue.java
common/concepts/src/test/java/org/opendaylight/yangtools/concepts/CheckedValueTest.java

index 0afa14002a88a55b02a5e0379046f00daa579c6c..1d6e2ecf300ddbaad0e815864c96d66c6339aa1a 100644 (file)
@@ -204,25 +204,6 @@ public class CheckedValue<T, E extends Exception> extends Either<T, E> {
         throw exceptionMapper.apply(second());
     }
 
-    /**
-     * Return contained value if present or throw the exception supplied by supplier.
-     *
-     * @param supplier Exception supplier
-     * @param <X> Thrown exception type
-     * @return Contained value
-     * @throws NullPointerException if {@code exceptionMapper} is null
-     * @throws X When there is no contained value
-     * @deprecated This method is losing the underlying failure cause. Use {@link #orElseThrow(Function)} instead.
-     */
-    @Deprecated(forRemoval = true, since = "8.0.2")
-    public final <X extends Throwable> T orElseThrow(final Supplier<X> supplier) throws X {
-        requireNonNull(supplier);
-        if (isFirst()) {
-            return first();
-        }
-        throw supplier.get();
-    }
-
     /**
      * Complete target {@link CompletableFuture} either successfully or exceptionally based on the state of this object.
      *
index 9ebaee5ef5afc61b3abc4e1c6672312089b961e1..98aae1e35f66cf1df5f10c603c2c9382211fbcd6 100644 (file)
@@ -136,20 +136,6 @@ public class CheckedValueTest {
         verifyNoInteractions(mapper);
     }
 
-    @Test
-    public void testOrElseThrow() {
-        final String foo = "foo";
-        assertSame(foo, CheckedValue.ofValue(foo)
-            .orElseThrow((Supplier<NullPointerException>)NullPointerException::new));
-    }
-
-    @Test
-    public void testThrowableOrElseThrow() {
-        final CheckedValue<?, ?> value = CheckedValue.ofException(new NullPointerException("foo"));
-        final Exception mock = mock(Exception.class);
-        assertThrows(mock.getClass(), () -> value.orElseThrow(() -> mock));
-    }
-
     @Test
     public void testOrElseGet() {
         final String foo = "foo";