### Question:
Optionals { public static <T, E extends Throwable> Optional<T> optionally( boolean condition, CheckedSupplier<? extends T, E> supplier) throws E { requireNonNull(supplier); return condition ? Optional.ofNullable(supplier.get()) : Optional.empty(); } private  Optionals(); static Optional<T> optionally(
      boolean condition, CheckedSupplier<? extends T, E> supplier); static Optional<T> optional(boolean condition, T value); static Premise ifPresent(
      OptionalInt optional, CheckedIntConsumer<E> consumer); static Premise ifPresent(
      OptionalLong optional, CheckedLongConsumer<E> consumer); static Premise ifPresent(
      OptionalDouble optional, CheckedDoubleConsumer<E> consumer); static Premise ifPresent(
      Optional<T> optional, CheckedConsumer<? super T, E> consumer); static Premise ifPresent(
      Optional<A> left, Optional<B> right, CheckedBiConsumer<? super A, ? super B, E> consumer); static Optional<R> mapBoth(
      Optional<A> left, Optional<B> right, CheckedBiFunction<? super A, ? super B, ? extends R, E> mapper); static Optional<R> flatMapBoth(
      Optional<A> left, Optional<B> right,
      CheckedBiFunction<? super A, ? super B, ? extends Optional<R>, E> mapper);  }### Answer:
@Test public void optionally_empty() { assertThat( optionally( false, () -> { throw new AssertionError(); })) .isEmpty(); }
@Test public void optionally_supplierReturnsNull() { assertThat(optionally(true, () -> null)).isEmpty(); }
@Test public void optionally_notEmpty() { assertThat(optionally(true, () -> "v")).hasValue("v"); }