@Test void mapSuccessFailure() { Lazy<String> sut = new Lazy<>(() -> "Hello"); Lazy<String> map = sut.map(s -> { throw new IllegalArgumentException("Too unfriendly."); }); calling(map::get) .shouldThrow(IllegalArgumentException.class) .withMessage("Too unfriendly."); }
public <U, E extends Exception> Lazy<U> map(ThrowingFunction<? super T, ? extends U, E> function) { return new Lazy<>(() -> tryGet().map(function).orElseThrow()); }
Lazy { public <U, E extends Exception> Lazy<U> map(ThrowingFunction<? super T, ? extends U, E> function) { return new Lazy<>(() -> tryGet().map(function).orElseThrow()); } }
Lazy { public <U, E extends Exception> Lazy<U> map(ThrowingFunction<? super T, ? extends U, E> function) { return new Lazy<>(() -> tryGet().map(function).orElseThrow()); } <E extends Exception> Lazy(ThrowingSupplier<T,E> supplier); }
Lazy { public <U, E extends Exception> Lazy<U> map(ThrowingFunction<? super T, ? extends U, E> function) { return new Lazy<>(() -> tryGet().map(function).orElseThrow()); } <E extends Exception> Lazy(ThrowingSupplier<T,E> supplier); Try<T> tryGet(); T get(); Optional<T> optional(); Stream<T> stream(); boolean isKnown(); boolean isKnownSuccess(); boolean isKnownFailure(); Lazy<U> map(ThrowingFunction<? super T, ? extends U, E> function); Lazy<U> flatMap(ThrowingFunction<? super T, Lazy<U>, E> function); }
Lazy { public <U, E extends Exception> Lazy<U> map(ThrowingFunction<? super T, ? extends U, E> function) { return new Lazy<>(() -> tryGet().map(function).orElseThrow()); } <E extends Exception> Lazy(ThrowingSupplier<T,E> supplier); Try<T> tryGet(); T get(); Optional<T> optional(); Stream<T> stream(); boolean isKnown(); boolean isKnownSuccess(); boolean isKnownFailure(); Lazy<U> map(ThrowingFunction<? super T, ? extends U, E> function); Lazy<U> flatMap(ThrowingFunction<? super T, Lazy<U>, E> function);  }