@Test public void toOptionFailureTest() { Try<Integer> success; success = new Failure<>(exception); Optional<Integer> option = success.toOption(); assertFalse(option.isPresent()); }
public Optional<E> toOption() { return isSuccess() ? Optional.ofNullable(asSuccess().getResult()) : Optional.<E>empty(); }
Try { public Optional<E> toOption() { return isSuccess() ? Optional.ofNullable(asSuccess().getResult()) : Optional.<E>empty(); } }
Try { public Optional<E> toOption() { return isSuccess() ? Optional.ofNullable(asSuccess().getResult()) : Optional.<E>empty(); }  }
Try { public Optional<E> toOption() { return isSuccess() ? Optional.ofNullable(asSuccess().getResult()) : Optional.<E>empty(); }  static Function<I, Try<O>> of(ThrowingFunction<I, O> function); static Function<I, Supplier<Try<O>>> lazyOf(ThrowingFunction<I, O> function); static Collector<Try<E>, ?, Map<Type, List<Try<E>>>> groupingBySuccess(); static TryCollector<E> collect(); abstract Type getType(); boolean isSuccess(); boolean isFailure(); Try<F> map(Function<E, F> mapper); Try<O> flatMap(Function<E, Try<O>> mapper); Optional<E> toOption(); E getOrThrow(); void ifPresent(Consumer<E> consumer); Success<E> asSuccess(); Failure<E> asFailure(); }
Try { public Optional<E> toOption() { return isSuccess() ? Optional.ofNullable(asSuccess().getResult()) : Optional.<E>empty(); }  static Function<I, Try<O>> of(ThrowingFunction<I, O> function); static Function<I, Supplier<Try<O>>> lazyOf(ThrowingFunction<I, O> function); static Collector<Try<E>, ?, Map<Type, List<Try<E>>>> groupingBySuccess(); static TryCollector<E> collect(); abstract Type getType(); boolean isSuccess(); boolean isFailure(); Try<F> map(Function<E, F> mapper); Try<O> flatMap(Function<E, Try<O>> mapper); Optional<E> toOption(); E getOrThrow(); void ifPresent(Consumer<E> consumer); Success<E> asSuccess(); Failure<E> asFailure();  }