@Test void trySupplyWithNullSupplier() { calling(() -> Try.trySupply(null)) .shouldThrow(NullPointerException.class); }
public static <T, E extends Throwable> Try<T> trySupply(ThrowingSupplier<? extends T,E> supplier) { requireNonNull(supplier); try { return success(supplier.get()); } catch (Throwable e) { return failure(e); } }
Try { public static <T, E extends Throwable> Try<T> trySupply(ThrowingSupplier<? extends T,E> supplier) { requireNonNull(supplier); try { return success(supplier.get()); } catch (Throwable e) { return failure(e); } } }
Try { public static <T, E extends Throwable> Try<T> trySupply(ThrowingSupplier<? extends T,E> supplier) { requireNonNull(supplier); try { return success(supplier.get()); } catch (Throwable e) { return failure(e); } }  }
Try { public static <T, E extends Throwable> Try<T> trySupply(ThrowingSupplier<? extends T,E> supplier) { requireNonNull(supplier); try { return success(supplier.get()); } catch (Throwable e) { return failure(e); } }  abstract boolean isSuccess(); abstract boolean isFailure(); abstract T orElseThrow(); abstract Throwable throwable(); abstract Try<U> map(ThrowingFunction<? super T,? extends U,? extends E> function); abstract Try<U> flatMap(ThrowingFunction<? super T,Try<U>,? extends E> function); abstract Try<R> combine(Try<U> other, ThrowingFunction2<? super T,? super U,? extends R,? extends E> function); abstract T orElse(T alternativeValue); abstract T orElseGet(Supplier<T> supplier); abstract Try<T> orElseTry(ThrowingSupplier<T,? extends E> supplier); abstract T orElseThrow(Supplier<? extends X> exceptionSupplier); abstract Try<T> throwIfError(); abstract Try<T> ifSuccess(Consumer<? super T> consumer); abstract Try<T> ifFailure(Consumer<? super Throwable> consumer); abstract Optional<T> toOptional(); abstract Stream<T> stream(); static Try<T> trySupply(ThrowingSupplier<? extends T,E> supplier); static Try<T> success(T value); static Try<T> failure(Throwable e); }
Try { public static <T, E extends Throwable> Try<T> trySupply(ThrowingSupplier<? extends T,E> supplier) { requireNonNull(supplier); try { return success(supplier.get()); } catch (Throwable e) { return failure(e); } }  abstract boolean isSuccess(); abstract boolean isFailure(); abstract T orElseThrow(); abstract Throwable throwable(); abstract Try<U> map(ThrowingFunction<? super T,? extends U,? extends E> function); abstract Try<U> flatMap(ThrowingFunction<? super T,Try<U>,? extends E> function); abstract Try<R> combine(Try<U> other, ThrowingFunction2<? super T,? super U,? extends R,? extends E> function); abstract T orElse(T alternativeValue); abstract T orElseGet(Supplier<T> supplier); abstract Try<T> orElseTry(ThrowingSupplier<T,? extends E> supplier); abstract T orElseThrow(Supplier<? extends X> exceptionSupplier); abstract Try<T> throwIfError(); abstract Try<T> ifSuccess(Consumer<? super T> consumer); abstract Try<T> ifFailure(Consumer<? super Throwable> consumer); abstract Optional<T> toOptional(); abstract Stream<T> stream(); static Try<T> trySupply(ThrowingSupplier<? extends T,E> supplier); static Try<T> success(T value); static Try<T> failure(Throwable e);  }