From: Robert Varga Date: Fri, 13 May 2022 13:00:30 +0000 (+0200) Subject: Remove CheckedValue.orElseThrow(Supplier) X-Git-Tag: v9.0.0~64 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=yangtools.git;a=commitdiff_plain;h=78fa55d4ff747ee6930fa346d76185cada1efa0f Remove CheckedValue.orElseThrow(Supplier) This method has been deprecated, remove it. Change-Id: Iacb84d93ffedcd000157a35807a9a9951553bbf1 Signed-off-by: Robert Varga --- diff --git a/common/concepts/src/main/java/org/opendaylight/yangtools/concepts/CheckedValue.java b/common/concepts/src/main/java/org/opendaylight/yangtools/concepts/CheckedValue.java index 0afa14002a..1d6e2ecf30 100644 --- a/common/concepts/src/main/java/org/opendaylight/yangtools/concepts/CheckedValue.java +++ b/common/concepts/src/main/java/org/opendaylight/yangtools/concepts/CheckedValue.java @@ -204,25 +204,6 @@ public class CheckedValue extends Either { throw exceptionMapper.apply(second()); } - /** - * Return contained value if present or throw the exception supplied by supplier. - * - * @param supplier Exception supplier - * @param 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 T orElseThrow(final Supplier 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. * diff --git a/common/concepts/src/test/java/org/opendaylight/yangtools/concepts/CheckedValueTest.java b/common/concepts/src/test/java/org/opendaylight/yangtools/concepts/CheckedValueTest.java index 9ebaee5ef5..98aae1e35f 100644 --- a/common/concepts/src/test/java/org/opendaylight/yangtools/concepts/CheckedValueTest.java +++ b/common/concepts/src/test/java/org/opendaylight/yangtools/concepts/CheckedValueTest.java @@ -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::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";