@Test void withValue() { String value = RandomStringUtils.randomAscii(10); OptionalUtil.with(Optional.of(value)) .ifPresent(consumer) .otherwise(runnable); verify(consumer, times(1)).accept(value); verify(runnable, never()).run(); }
public static <T> OptionalWrapper<T> with(Optional<T> optional) { return new OptionalWrapper<>(optional); }
OptionalUtil extends UtilityClass { public static <T> OptionalWrapper<T> with(Optional<T> optional) { return new OptionalWrapper<>(optional); } }
OptionalUtil extends UtilityClass { public static <T> OptionalWrapper<T> with(Optional<T> optional) { return new OptionalWrapper<>(optional); }  }
OptionalUtil extends UtilityClass { public static <T> OptionalWrapper<T> with(Optional<T> optional) { return new OptionalWrapper<>(optional); }  static Optional<T> ofBlankable(T s); static Optional<T> ofOnly(Iterable<T> iterable); static OptionalWrapper<T> with(Optional<T> optional); static Optional<T> or(Optional<T> optional, Optional<T> other); static Optional<T> orGet(Optional<T> optional, Supplier<? extends Optional<? extends T>> supplier); static Optional<U> as(Class<U> targetClass, Optional<T> source); @SuppressWarnings("unchecked") static Optional<U> as(TypeToken<U> targetType, Optional<T> source); static Optional<U> as(Class<U> targetClass, T source); @SuppressWarnings("unchecked") static Optional<U> as(TypeToken<U> targetType, T source); }
OptionalUtil extends UtilityClass { public static <T> OptionalWrapper<T> with(Optional<T> optional) { return new OptionalWrapper<>(optional); }  static Optional<T> ofBlankable(T s); static Optional<T> ofOnly(Iterable<T> iterable); static OptionalWrapper<T> with(Optional<T> optional); static Optional<T> or(Optional<T> optional, Optional<T> other); static Optional<T> orGet(Optional<T> optional, Supplier<? extends Optional<? extends T>> supplier); static Optional<U> as(Class<U> targetClass, Optional<T> source); @SuppressWarnings("unchecked") static Optional<U> as(TypeToken<U> targetType, Optional<T> source); static Optional<U> as(Class<U> targetClass, T source); @SuppressWarnings("unchecked") static Optional<U> as(TypeToken<U> targetType, T source);  }