Result implements Serializable { public abstract V getOrDefault(final V defaultValue); 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);  }
@Test public void testGetOrDefault() { final String defaultValue = "defaultValue"; assertNotEquals("success gets non-default", defaultValue, Result.success("success").getOrDefault(defaultValue)); assertEquals("failure gets default", defaultValue, Result.failure("failure").getOrDefault(defaultValue)); }