@Test void ifEmptyShouldPreserveValueOfEmptyOptionals() { Optional<Object> expected = OptionalUtils.executeIfEmpty(Optional.empty(), () -> { }); assertThat(expected).isEmpty(); }
public static <T> Optional<T> executeIfEmpty(Optional<T> optional, Operation operation) { if (!optional.isPresent()) { operation.perform(); } return optional; }
OptionalUtils { public static <T> Optional<T> executeIfEmpty(Optional<T> optional, Operation operation) { if (!optional.isPresent()) { operation.perform(); } return optional; } }
OptionalUtils { public static <T> Optional<T> executeIfEmpty(Optional<T> optional, Operation operation) { if (!optional.isPresent()) { operation.perform(); } return optional; }  }
OptionalUtils { public static <T> Optional<T> executeIfEmpty(Optional<T> optional, Operation operation) { if (!optional.isPresent()) { operation.perform(); } return optional; }  static Optional<T> executeIfEmpty(Optional<T> optional, Operation operation); static boolean containsDifferent(Optional<T> requestValue, T storeValue); static boolean matches(Optional<T> optional1, Optional<U> optional2, BiPredicate<T, U> biPredicate); }
OptionalUtils { public static <T> Optional<T> executeIfEmpty(Optional<T> optional, Operation operation) { if (!optional.isPresent()) { operation.perform(); } return optional; }  static Optional<T> executeIfEmpty(Optional<T> optional, Operation operation); static boolean containsDifferent(Optional<T> requestValue, T storeValue); static boolean matches(Optional<T> optional1, Optional<U> optional2, BiPredicate<T, U> biPredicate);  }