@Test public void testToOptional() { assertTrue("success is present", Result.success("success").toOptional().isPresent()); assertFalse("failure is not present", Result.failure("failure").toOptional().isPresent()); }
@SuppressWarnings("WeakerAccess") public final Optional<V> toOptional() { return stream().findFirst(); }
Result implements Serializable { @SuppressWarnings("WeakerAccess") public final Optional<V> toOptional() { return stream().findFirst(); } }
Result implements Serializable { @SuppressWarnings("WeakerAccess") public final Optional<V> toOptional() { return stream().findFirst(); } private  Result(); }
Result implements Serializable { @SuppressWarnings("WeakerAccess") public final Optional<V> toOptional() { return stream().findFirst(); } private  Result(); abstract Result<W> map(final @NotNull Function<? super V, W> f); abstract Result<W> flatMap(final @NotNull Function<? super V, Result<W>> f); abstract V getOrDefault(final V defaultValue); abstract V getOrElse(final @NotNull Supplier<? extends V> defaultValue); abstract Result<V> orElse(final @NotNull Supplier<Result<V>> defaultValue); abstract Stream<V> stream(); abstract Result<V> teeLogError(); final boolean isSuccess(); final boolean isFailure(); @SuppressWarnings("WeakerAccess") final Optional<V> toOptional(); abstract Optional<RuntimeException> getError(); @SuppressWarnings("WeakerAccess") final Optional<Throwable> findCause(final @NotNull Predicate<? super Throwable> predicate); @SuppressWarnings("WeakerAccess") final Optional<E> findCause(final @NotNull Class<E> errorType); final void throwCause(final @NotNull Class<E> errorType); abstract void forEach(final @NotNull Consumer<? super V> consumer); static Result<V> failure(final String message); static Result<V> failure(final @NotNull Exception e); static Result<V> failure(final @NotNull String message, final @NotNull Exception e); static Result<V> failure(final @NotNull RuntimeException e); static Result<V> success(final V value); static Collector<Result<V>, Builder<V, A>, Result<R>> tryCollect(final @NotNull Collector<V, A, R> collector); static Collector<Result<V>, Stream.Builder<Result<V>>, Stream<Result<V>>> logAndRestream(); static Collector<Result<V>, Stream.Builder<Result<V>>, Stream<Result<V>>> logAndRestream(final @NotNull String message); }
Result implements Serializable { @SuppressWarnings("WeakerAccess") public final Optional<V> toOptional() { return stream().findFirst(); } private  Result(); abstract Result<W> map(final @NotNull Function<? super V, W> f); abstract Result<W> flatMap(final @NotNull Function<? super V, Result<W>> f); abstract V getOrDefault(final V defaultValue); abstract V getOrElse(final @NotNull Supplier<? extends V> defaultValue); abstract Result<V> orElse(final @NotNull Supplier<Result<V>> defaultValue); abstract Stream<V> stream(); abstract Result<V> teeLogError(); final boolean isSuccess(); final boolean isFailure(); @SuppressWarnings("WeakerAccess") final Optional<V> toOptional(); abstract Optional<RuntimeException> getError(); @SuppressWarnings("WeakerAccess") final Optional<Throwable> findCause(final @NotNull Predicate<? super Throwable> predicate); @SuppressWarnings("WeakerAccess") final Optional<E> findCause(final @NotNull Class<E> errorType); final void throwCause(final @NotNull Class<E> errorType); abstract void forEach(final @NotNull Consumer<? super V> consumer); static Result<V> failure(final String message); static Result<V> failure(final @NotNull Exception e); static Result<V> failure(final @NotNull String message, final @NotNull Exception e); static Result<V> failure(final @NotNull RuntimeException e); static Result<V> success(final V value); static Collector<Result<V>, Builder<V, A>, Result<R>> tryCollect(final @NotNull Collector<V, A, R> collector); static Collector<Result<V>, Stream.Builder<Result<V>>, Stream<Result<V>>> logAndRestream(); static Collector<Result<V>, Stream.Builder<Result<V>>, Stream<Result<V>>> logAndRestream(final @NotNull String message);  }