/** * Map the failure of a future to {@code null}.<p> * * This is a convenience for {@code future.otherwise((T) null)}.<p> * * When this future fails, the {@code null} value will complete the future returned by this method call.<p> * * When this future succeeds, the result will be propagated to the returned future. * * @return the mapped future */ default Future<T> otherwiseEmpty() { return (Future<T>) AsyncResult.super.otherwiseEmpty(); }
private void testOtherwiseEmpty(AsyncResult<String> res, Future<String> f) { AsyncResult<String> otherwise = res.otherwiseEmpty(); Throwable cause = new Throwable("the-failure"); f.fail(cause); assertTrue(otherwise.succeeded()); assertFalse(otherwise.failed()); assertEquals(null, otherwise.result()); assertNull(otherwise.cause()); }
/** * Map the failure of a future to {@code null}.<p> * * This is a convenience for {@code future.otherwise((T) null)}.<p> * * When this future fails, the {@code null} value will complete the future returned by this method call.<p> * * When this future succeeds, the result will be propagated to the returned future. * * @return the mapped future */ default Future<T> otherwiseEmpty() { return (Future<T>) AsyncResult.super.otherwiseEmpty(); }
private void testOtherwiseEmpty(AsyncResult<String> res, Future<String> f) { AsyncResult<String> otherwise = res.otherwiseEmpty(); Throwable cause = new Throwable("the-failure"); f.fail(cause); assertTrue(otherwise.succeeded()); assertFalse(otherwise.failed()); assertEquals(null, otherwise.result()); assertNull(otherwise.cause()); }